File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ def update(self, updates):
7575 """
7676 Update any configuration variable dynamically.
7777 Accepts a dict or a list of (key, value) pairs.
78+ Also updates dependent variables if their base values change.
7879 Example:
7980 cfg.update({'BATCH_SIZE': 32, 'LR': 5e-4})
8081 cfg.update([('BATCH_SIZE', 32), ('LR', 5e-4)])
@@ -90,3 +91,12 @@ def update(self, updates):
9091 setattr (self , key , value )
9192 else :
9293 raise AttributeError (f"TrainingConfig has no attribute '{ key } '" )
94+ # Update dependent variables if their base values changed
95+ if 'MODEL_NAME' in dict (items ) or 'CACHE_DIR' in dict (items ) or 'MODEL_ROUND' in dict (items ):
96+ self .LOG_FILE = f"{ self .CACHE_DIR } /{ self .MODEL_NAME } /training.log"
97+ self .EMBED_CACHE_DIR = f"{ self .CACHE_DIR } /{ self .MODEL_NAME } /round_{ self .MODEL_ROUND } /embeddings"
98+ self .writer = SummaryWriter (log_dir = f"{ self .CACHE_DIR } /{ self .MODEL_NAME } /round_{ self .MODEL_ROUND } /tensorboard_logs" )
99+ os .makedirs (self .EMBED_CACHE_DIR , exist_ok = True )
100+ if 'CACHE_DIR' in dict (items ):
101+ self .DATA_CACHE_DIR = f"{ self .CACHE_DIR } /dataset"
102+ os .makedirs (self .DATA_CACHE_DIR , exist_ok = True )
You can’t perform that action at this time.
0 commit comments