HazyResearch / hippo-code

Apache License 2.0
168 stars 30 forks source link

cfg.seed error due to a nonaligned version in my conda env? #2

Closed jabowery closed 3 years ago

jabowery commented 3 years ago

To run the train.py examples, I found I needed to change the calls that passed cfg.seed to explicitly calculate the uniform distribution randomly generated seed. Perhaps this was due to a failure on my part to properly align versions in my conda environment since I found I had to also install from github source the omegaconf module.

Here is the change I made:

diff --git a/pl_runner.py b/pl_runner.py
index 2979a89..5c84a63 100644
--- a/pl_runner.py
+++ b/pl_runner.py
@@ -3,10 +3,12 @@ import pytorch_lightning as pl

 def pl_train(cfg, pl_model_class):
+    from random import randint
     if cfg.seed is not None:
-        torch.manual_seed(cfg.seed)
+        seed=randint(cfg.seed[1],cfg.seed[2])
+        torch.manual_seed(seed)
         if torch.cuda.is_available():
-            torch.cuda.manual_seed(cfg.seed)
+            torch.cuda.manual_seed(seed)
     model = pl_model_class(cfg.model, cfg.dataset, cfg.train)
     if 'pl' in cfg and 'profile' in cfg.pl and cfg.pl.profile:
         # profiler=pl.profiler.AdvancedProfiler(output_filename=cfg.train.profiler),
diff --git a/requirements.txt b/requirements.txt
index f06f0ed..2882772 100644
--- a/requirements.txt
+++ b/requirements.txt
tridao commented 3 years ago

Thanks for the bug report! The seed in our config file was in the wrong format. I've fixed it with the latest commit.