Reinforcement Learning
stable-baselines3
deep-reinforcement-learning
agricultural-ai
weather-modelling
curriculum-learning
edge-ai
Instructions to use DHDRL/monsoon-rl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use DHDRL/monsoon-rl with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="DHDRL/monsoon-rl", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Update test_injection_guard.py
Browse files27 unmodified lines2829303132333410 unmodified lines4546474849505119 unmodified lines7172737475767778798081828313 unmodified lines9798991001011021031041051061072 unmodified lines11011111211327 unmodified linesprint("test_injection_guard")# n_zones=1 + inject must succeedcfg1 = ForecastConfig(n_zones=1, max_steps=4, horizon_days=30)env1 = make_weather_env(cfg1, use_nan_wrapper=True)obs = make_synthetic_zone_obs("karawang_rice", drought=True, seed=1)10 unmodified linesassert o["zone_belief"].shape[0] >= 1print(" n_zones=1 inject OK")# n_zones=3 + inject WITHOUT zone_obs lists must raise (not pad)cfg3 = ForecastConfig(n_zones=3, max_steps=6, horizon_days=30)env3 = make_weather_env(cfg3, use_nan_wrapper=True)ctx_bad = EpisodeContext(19 unmodified linesprint(" FAIL: n_zones=3 inject did not raise — padding bug may still be live")return 1# n_zones=3 + inject WITH explicit per-zone lists must succeed (Blocker B)zids = ["karawang_rice", "indramayu_rice", "central_java_rice"]z_obs = [make_synthetic_zone_obs(z, drought=(i == 0), flood=(i == 1), seed=10 + i)for i, z in enumerate(zids)]# Align valid_time so forecasts share a coherent episode clockvt = z_obs[0].valid_timefor zo in z_obs:zo.valid_time = vt13 unmodified lines)o_ok, info_ok = env3.reset(options={"context": ctx_ok})assert o_ok["zone_belief"].shape[0] >= 3# Beliefs should differ across zones (different event flags / noise)zb = o_ok["zone_belief"][:3]print(f" n_zones=3 inject with lists OK zone_belief={zb.tolist()}")# Training path (no inject) must still work at n_zones=3o3, _ = env3.reset(seed=0)assert o3["zone_belief"].shape[0] >= 3print(" n_zones=3 synthetic training reset OK")2 unmodified linesif __name__ == "__main__":raise SystemExit(main())27 unmodified lines28293031323310 unmodified lines44454647484919 unmodified lines697071727374757677787913 unmodified lines939495969798991001012 unmodified lines10410510610727 unmodified linesprint("test_injection_guard")cfg1 = ForecastConfig(n_zones=1, max_steps=4, horizon_days=30)env1 = make_weather_env(cfg1, use_nan_wrapper=True)obs = make_synthetic_zone_obs("karawang_rice", drought=True, seed=1)10 unmodified linesassert o["zone_belief"].shape[0] >= 1print(" n_zones=1 inject OK")cfg3 = ForecastConfig(n_zones=3, max_steps=6, horizon_days=30)env3 = make_weather_env(cfg3, use_nan_wrapper=True)ctx_bad = EpisodeContext(19 unmodified linesprint(" FAIL: n_zones=3 inject did not raise — padding bug may still be live")return 1zids = ["karawang_rice", "indramayu_rice", "central_java_rice"]z_obs = [make_synthetic_zone_obs(z, drought=(i == 0), flood=(i == 1), seed=10 + i)for i, z in enumerate(zids)]vt = z_obs[0].valid_timefor zo in z_obs:zo.valid_time = vt13 unmodified lines)o_ok, info_ok = env3.reset(options={"context": ctx_ok})assert o_ok["zone_belief"].shape[0] >= 3zb = o_ok["zone_belief"][:3]print(f" n_zones=3 inject with lists OK zone_belief={zb.tolist()}")o3, _ = env3.reset(seed=0)assert o3["zone_belief"].shape[0] >= 3print(" n_zones=3 synthetic training reset OK")2 unmodified linesif __name__ == "__main__":raise SystemExit(main())
test_injection_guard.py+1-7