Skip to content

Commit 637fd50

Browse files
committed
rng_seed, saving sets final episode
1 parent 349d541 commit 637fd50

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

pycls/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
_C.CFG_DEST = 'config.yaml'
3333
# Note that non-determinism may still be present due to non-deterministic
3434
# operator implementations in GPU operator libraries
35-
_C.RNG_SEED = 1
35+
_C.RNG_SEED = None
3636
# Folder name where best model logs etc are saved. "auto" creates a timestamp based folder
3737
_C.EXP_NAME = 'auto'
3838
# Which GPU to run on

tools/ensemble_al.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def main(cfg):
102102
device = torch.device("cuda" if use_cuda else "cpu")
103103
kwargs = {'num_workers': cfg.DATA_LOADER.NUM_WORKERS, 'pin_memory': cfg.DATA_LOADER.PIN_MEMORY} if use_cuda else {}
104104

105+
# Auto assign a RNG_SEED when not supplied a value
106+
if cfg.RNG_SEED is None:
107+
cfg.RNG_SEED = np.random.randint(100)
108+
105109
# Using specific GPU
106110
# os.environ['NVIDIA_VISIBLE_DEVICES'] = str(cfg.GPU_ID)
107111
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
@@ -253,6 +257,9 @@ def main(cfg):
253257

254258
# No need to perform active sampling in the last episode iteration
255259
if cur_episode == cfg.ACTIVE_LEARNING.MAX_ITER:
260+
# Save lSet, uSet in the final episode directory
261+
data_obj.saveSet(lSet, 'lSet', cfg.EPISODE_DIR)
262+
data_obj.saveSet(uSet, 'uSet', cfg.EPISODE_DIR)
256263
break
257264

258265
# Active Sample

tools/ensemble_train.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def main(cfg):
102102
device = torch.device("cuda" if use_cuda else "cpu")
103103
kwargs = {'num_workers': cfg.DATA_LOADER.NUM_WORKERS, 'pin_memory': cfg.DATA_LOADER.PIN_MEMORY} if use_cuda else {}
104104

105+
# Auto assign a RNG_SEED when not supplied a value
106+
if cfg.RNG_SEED is None:
107+
cfg.RNG_SEED = np.random.randint(100)
108+
105109
# Using specific GPU
106110
# os.environ['NVIDIA_VISIBLE_DEVICES'] = str(cfg.GPU_ID)
107111
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'

tools/train.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_path(path):
4040
def argparser():
4141
parser = argparse.ArgumentParser(description='Passive Learning - Image Classification')
4242
parser.add_argument('--cfg', dest='cfg_file', help='Config file', required=True, type=str)
43-
43+
parser.add_argument('--exp-name', dest='exp_name', help='Experiment Name', required=True, type=str)
4444
return parser
4545

4646
def plot_arrays(x_vals, y_vals, x_name, y_name, dataset_name, out_dir, isDebug=False):
@@ -97,6 +97,10 @@ def main(cfg):
9797
device = torch.device("cuda" if use_cuda else "cpu")
9898
kwargs = {'num_workers': cfg.DATA_LOADER.NUM_WORKERS, 'pin_memory': cfg.DATA_LOADER.PIN_MEMORY} if use_cuda else {}
9999

100+
# Auto assign a RNG_SEED when not supplied a value
101+
if cfg.RNG_SEED is None:
102+
cfg.RNG_SEED = np.random.randint(100)
103+
100104
# Using specific GPU
101105
# os.environ['CUDA_VISIBLE_DEVICES'] = str(cfg.GPU_ID)
102106
# print("Using GPU : {}.\n".format(cfg.GPU_ID))
@@ -452,4 +456,5 @@ def test_epoch(test_loader, model, test_meter, cur_epoch):
452456

453457
if __name__ == "__main__":
454458
cfg.merge_from_file(argparser().parse_args().cfg_file)
459+
cfg.EXP_NAME = argparser().parse_args().exp_name
455460
main(cfg)

tools/train_al.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def main(cfg):
103103
device = torch.device("cuda" if use_cuda else "cpu")
104104
kwargs = {'num_workers': cfg.DATA_LOADER.NUM_WORKERS, 'pin_memory': cfg.DATA_LOADER.PIN_MEMORY} if use_cuda else {}
105105

106+
# Auto assign a RNG_SEED when not supplied a value
107+
if cfg.RNG_SEED is None:
108+
cfg.RNG_SEED = np.random.randint(100)
109+
106110
# Using specific GPU
107111
# os.environ['NVIDIA_VISIBLE_DEVICES'] = str(cfg.GPU_ID)
108112
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
@@ -209,6 +213,9 @@ def main(cfg):
209213

210214
# No need to perform active sampling in the last episode iteration
211215
if cur_episode == cfg.ACTIVE_LEARNING.MAX_ITER:
216+
# Save current lSet, uSet in the final episode directory
217+
data_obj.saveSet(lSet, 'lSet', cfg.EPISODE_DIR)
218+
data_obj.saveSet(uSet, 'uSet', cfg.EPISODE_DIR)
212219
break
213220

214221
# Active Sample

0 commit comments

Comments
 (0)