flâneur — a map of the web's best reading

ModelCheckpoint — PyTorch Lightning 2.4.0 documentation

lightning.ai · 2,336 words · saved by 1 readers

Save the model periodically by monitoring a quantity. Every metric logged with log() or log_dict() is a candidate for the monitor key. For more information, see Checkpointing. After training finishes, use best_model_path to retrieve the path to the best checkpoint file and best_model_score to retrieve its score. dirpath (Union[str, Path, None]) – directory to save the model file. Example: By default, dirpath is None and will be set at runtime to the location specified by Trainer’s default_root_dir argument, and if the Trainer uses a logger, the path will also contain logger name and version. filename (Optional[str]) – checkpoint filename. Can contain named formatting options to be auto-filled. Example: By default, filename is None and will be set to '{epoch}-{step}', where “epoch” and “step” match the number of finished epoch and optimizer steps respectively. monitor (Optional[str]) – quantity to monitor. By default it is None which saves a checkpoint only for the last epoch. verbos

ModelCheckpoint ¶ class lightning.pytorch.callbacks. ModelCheckpoint ( dirpath = None , filename = None , monitor = None , verbose = False , save_last = None , save_top_k = 1 , save_on_exception = False , save_weights_only = False , mode = 'min' , auto_insert_metric_name = True , every_n_train_steps = None , train_time_interval = None , every_n_epochs = None , save_on_train_epoch_end = None , enable_version_counter = True ) [source] ¶ Bases: Checkpoint Save the model after every epoch by monitoring a quantity. Every logged metrics are passed to the Logger for the version it gets saved in the s

Explore this link on the map →

related reading