You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# best = float(oracles[oracles[self.metric_to_rank_by]
592
+
# != self.metric_to_rank_by]
593
+
# [self.metric_to_rank_by].astype(float).min())
580
594
print(f"Best result this trial was: {best}")
581
595
print(f"Type of best result: {type(best)}")
582
596
self.best_model_path=\
@@ -585,8 +599,63 @@ def run_random_search(self):
585
599
print(f"Best model name: {self.best_model_path}")
586
600
returnbest
587
601
588
-
defget_best_model(self):
602
+
defpurge_model_storage(self) ->None:
603
+
"""Slates all cached models.
604
+
Recommended when running in a container without a mounted volume.
605
+
It is recommened to use an artifiact registry to accession the best model.
606
+
"""
607
+
model_cache_path=f"{self.project_name}/models"
608
+
rmtree(model_cache_path)
609
+
610
+
611
+
defpurge_models_except_best_model(self) ->None:
612
+
"""
613
+
Recommended when running in a container without a mounted volume and building models that take considerable time to reproduce.
614
+
It is recommened to use an artifiact registry to accession the best model, but this will preserve a redundant
615
+
copy in case accessioning it to a registry is unsuccessful.
616
+
"""
617
+
ifnotself.best_model_path:
618
+
returnValueError("The function purge_models_except_best_model was called prematurely: self.best_model_path is not set, maining there is no 'Best model'.")
Optionally, purges cache of models stored on disk.
637
+
638
+
Params:
639
+
- purge_model_storage_files Union[str, int]
640
+
- Set to 0: Does not purge the cached modelsl, just returns the best model.
641
+
- Set to 1: Purges all models except the best model found.
642
+
- Set to "slate": Removes all models, whether the best or otherwise.
643
+
When running ephemeral trials in a container without a mounted volume (to prevent
644
+
memory pressure accumulating from ephemeral files in memory) or are otherwise working
645
+
with hard disk space limitations, we recommend setting this:
646
+
- 'slate': if you are working on models that are quick to reproduce and an accidental model loss is not problematic as long as you have the parameters to reproduce it approximately.
647
+
- 1: If you are are workign on models that take considerable time to reproduce a given model or a small performance difference from another model from the same parameters is problematic.
648
+
- 0 If you have unlimited disk space and are not in a container or in one with a suitable mounted volume.
raiseValueError("The paramerter purge_model_storage_files in the method get_best_model() has 3 values: 0 (Don't purge),1 (Purge all but the best model), 'slate' (remove all cached models) ")
Copy file name to clipboardExpand all lines: phishing_email_detection_gpt2.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -515,6 +515,7 @@ def from_config(cls, config):
515
515
516
516
517
517
518
+
518
519
print(f"Cerebros trained {models_tried} models FROM A COLD START in ONLY {cerebros_time_all_models_min} min. Cerebros took only {cerebros_time_per_model} minutes on average per model.")
519
520
print(f"GPT2 took {gpt_time_on_one_model_min} just to FINE TUNE one PRE - TRAINED model for 3 epochs. Although this is a small scale test, this shows the advantage of scaling in ON timing VS ON**2 timing.")
520
521
print(f'Cerebros best accuracy achieved is {result}')
0 commit comments