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 train_kaggle.py
Browse files- train_kaggle.py +21 -1
train_kaggle.py
CHANGED
|
@@ -21,6 +21,23 @@ logging.basicConfig(
|
|
| 21 |
)
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def _add_file_logging(out_dir: Path) -> None:
|
| 25 |
formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(message)s")
|
| 26 |
file_handler = logging.FileHandler(str(out_dir / "training.log"))
|
|
@@ -235,6 +252,7 @@ def build_model(args: argparse.Namespace, train_env):
|
|
| 235 |
device=args.device,
|
| 236 |
verbose=1,
|
| 237 |
tensorboard_log=tb_log,
|
|
|
|
| 238 |
)
|
| 239 |
|
| 240 |
|
|
@@ -390,9 +408,11 @@ def run_training(args: argparse.Namespace) -> None:
|
|
| 390 |
|
| 391 |
def main() -> None:
|
| 392 |
args = _parse_args()
|
|
|
|
|
|
|
| 393 |
_add_dataset_to_path(args.dataset_dir)
|
| 394 |
run_training(args)
|
| 395 |
|
| 396 |
|
| 397 |
if __name__ == "__main__":
|
| 398 |
-
main()
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
|
| 24 |
+
def set_global_seeds(seed: int) -> None:
|
| 25 |
+
"""Seed Python, NumPy, and PyTorch so that --seed controls weight init
|
| 26 |
+
as well as environment episode generation.
|
| 27 |
+
"""
|
| 28 |
+
import random
|
| 29 |
+
import numpy as np
|
| 30 |
+
random.seed(seed)
|
| 31 |
+
np.random.seed(seed)
|
| 32 |
+
try:
|
| 33 |
+
import torch
|
| 34 |
+
torch.manual_seed(seed)
|
| 35 |
+
if torch.cuda.is_available():
|
| 36 |
+
torch.cuda.manual_seed_all(seed)
|
| 37 |
+
except ImportError:
|
| 38 |
+
pass
|
| 39 |
+
|
| 40 |
+
|
| 41 |
def _add_file_logging(out_dir: Path) -> None:
|
| 42 |
formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(message)s")
|
| 43 |
file_handler = logging.FileHandler(str(out_dir / "training.log"))
|
|
|
|
| 252 |
device=args.device,
|
| 253 |
verbose=1,
|
| 254 |
tensorboard_log=tb_log,
|
| 255 |
+
seed=args.seed, # weight-init + SB3 internal RNG; env already seeded via ForecastConfig
|
| 256 |
)
|
| 257 |
|
| 258 |
|
|
|
|
| 408 |
|
| 409 |
def main() -> None:
|
| 410 |
args = _parse_args()
|
| 411 |
+
set_global_seeds(args.seed)
|
| 412 |
+
logger.info("Global seeds set to %s (Python / NumPy / PyTorch)", args.seed)
|
| 413 |
_add_dataset_to_path(args.dataset_dir)
|
| 414 |
run_training(args)
|
| 415 |
|
| 416 |
|
| 417 |
if __name__ == "__main__":
|
| 418 |
+
main()
|