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 build_dynamics_pairs.py
Browse files- build_dynamics_pairs.py +0 -18
build_dynamics_pairs.py
CHANGED
|
@@ -2,11 +2,6 @@
|
|
| 2 |
"""
|
| 3 |
build_dynamics_pairs.py
|
| 4 |
=======================
|
| 5 |
-
Last-mile path: historical cache → (current, next) ZoneStateTensor pairs
|
| 6 |
-
for physics_dynamics.DynamicsTrainer.
|
| 7 |
-
|
| 8 |
-
Previously the Dyna module was fully unit-tested but had no script that
|
| 9 |
-
turned real trajectories into training pairs. This closes that gap.
|
| 10 |
|
| 11 |
Contract
|
| 12 |
--------
|
|
@@ -65,12 +60,6 @@ def _forecast_precip_array(fc: Dict[str, Any], horizon_days: int) -> np.ndarray:
|
|
| 65 |
|
| 66 |
|
| 67 |
def _belief_uncertainty_from_obs(obs: Dict[str, Any]) -> Tuple[float, float]:
|
| 68 |
-
"""
|
| 69 |
-
Proxy scalars so pairs need no trained agent.
|
| 70 |
-
|
| 71 |
-
belief ~ max of clipped anomaly magnitudes mapped to [0,1]
|
| 72 |
-
uncertainty ~ higher when quality_flag low / cloud high
|
| 73 |
-
"""
|
| 74 |
anom = abs(float(obs.get("precip_anomaly_idx") or 0.0))
|
| 75 |
soil = abs(float(obs.get("soil_moisture_anom") or 0.0))
|
| 76 |
belief = float(np.clip(max(anom, soil) / 3.0, 0.0, 1.0))
|
|
@@ -87,13 +76,6 @@ def extract_pairs_from_pkl(
|
|
| 87 |
start: Optional[date] = None,
|
| 88 |
end: Optional[date] = None,
|
| 89 |
) -> Tuple[List[Tuple[Any, Any]], List[float], Dict[str, Any]]:
|
| 90 |
-
"""
|
| 91 |
-
Build consecutive pairs within each trajectory (same zone, ordered time).
|
| 92 |
-
|
| 93 |
-
Returns (pairs, dts, manifest_stats). dts[i] is the real-time gap in days
|
| 94 |
-
for pairs[i] (exact step_days only). Requires torch only when materializing
|
| 95 |
-
ZoneStateTensor — import deferred so --help works offline.
|
| 96 |
-
"""
|
| 97 |
import torch
|
| 98 |
from physics_dynamics import ZoneStateTensor
|
| 99 |
|
|
|
|
| 2 |
"""
|
| 3 |
build_dynamics_pairs.py
|
| 4 |
=======================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
Contract
|
| 7 |
--------
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def _belief_uncertainty_from_obs(obs: Dict[str, Any]) -> Tuple[float, float]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
anom = abs(float(obs.get("precip_anomaly_idx") or 0.0))
|
| 64 |
soil = abs(float(obs.get("soil_moisture_anom") or 0.0))
|
| 65 |
belief = float(np.clip(max(anom, soil) / 3.0, 0.0, 1.0))
|
|
|
|
| 76 |
start: Optional[date] = None,
|
| 77 |
end: Optional[date] = None,
|
| 78 |
) -> Tuple[List[Tuple[Any, Any]], List[float], Dict[str, Any]]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
import torch
|
| 80 |
from physics_dynamics import ZoneStateTensor
|
| 81 |
|