@@ -86,26 +86,14 @@ class ModelCheckpoint(Callback):
8686 if ``save_top_k >= 2`` and the callback is called multiple
8787 times inside an epoch, the name of the saved file will be
8888 appended with a version count starting with ``v1``.
89- mode: one of {auto, min, max}.
90- If ``save_top_k != 0``, the decision
91- to overwrite the current save file is made
92- based on either the maximization or the
93- minimization of the monitored quantity. For `val_acc`,
94- this should be `max`, for `val_loss` this should
95- be `min`, etc. In `auto` mode, the direction is
96- automatically inferred from the name of the monitored quantity.
97-
98- .. warning::
99- Setting ``mode='auto'`` has been deprecated in v1.1 and will be removed in v1.3.
100-
89+ mode: one of {min, max}.
90+ If ``save_top_k != 0``, the decision to overwrite the current save file is made
91+ based on either the maximization or the minimization of the monitored quantity.
92+ For ``'val_acc'``, this should be ``'max'``, for ``'val_loss'`` this should be ``'min'``, etc.
10193 save_weights_only: if ``True``, then only the model's weights will be
10294 saved (``model.save_weights(filepath)``), else the full model
10395 is saved (``model.save(filepath)``).
10496 period: Interval (number of epochs) between checkpoints.
105- prefix: A string to put at the beginning of checkpoint filename.
106-
107- .. warning::
108- This argument has been deprecated in v1.1 and will be removed in v1.3
10997
11098 Note:
11199 For extra customization, ModelCheckpoint includes the following attributes:
@@ -122,7 +110,7 @@ class ModelCheckpoint(Callback):
122110 MisconfigurationException:
123111 If ``save_top_k`` is neither ``None`` nor more than or equal to ``-1``,
124112 if ``monitor`` is ``None`` and ``save_top_k`` is none of ``None``, ``-1``, and ``0``, or
125- if ``mode`` is none of ``"min"``, ``"max"``, and ``"auto "``.
113+ if ``mode`` is none of ``"min"`` or ``"max "``.
126114 ValueError:
127115 If ``trainer.save_checkpoint`` is ``None``.
128116
@@ -166,9 +154,8 @@ def __init__(
166154 save_last : Optional [bool ] = None ,
167155 save_top_k : Optional [int ] = None ,
168156 save_weights_only : bool = False ,
169- mode : str = "auto " ,
157+ mode : str = "min " ,
170158 period : int = 1 ,
171- prefix : str = "" ,
172159 ):
173160 super ().__init__ ()
174161 self .monitor = monitor
@@ -178,7 +165,6 @@ def __init__(
178165 self .save_weights_only = save_weights_only
179166 self .period = period
180167 self ._last_global_step_saved = - 1
181- self .prefix = prefix
182168 self .current_score = None
183169 self .best_k_models = {}
184170 self .kth_best_model_path = ""
@@ -188,12 +174,6 @@ def __init__(
188174 self .save_function = None
189175 self .warned_result_obj = False
190176
191- if prefix :
192- rank_zero_warn (
193- 'Argument `prefix` is deprecated in v1.1 and will be removed in v1.3.'
194- ' Please prepend your prefix in `filename` instead.' , DeprecationWarning
195- )
196-
197177 self .__init_monitor_mode (monitor , mode )
198178 self .__init_ckpt_dir (dirpath , filename , save_top_k )
199179 self .__validate_init_configuration ()
@@ -300,18 +280,8 @@ def __init_monitor_mode(self, monitor, mode):
300280 "max" : (- torch_inf , "max" ),
301281 }
302282
303- if mode not in mode_dict and mode != 'auto' :
304- raise MisconfigurationException (f"`mode` can be auto, { ', ' .join (mode_dict .keys ())} , got { mode } " )
305-
306- # TODO: Update with MisconfigurationException when auto mode is removed in v1.3
307- if mode == 'auto' :
308- rank_zero_warn (
309- "mode='auto' is deprecated in v1.1 and will be removed in v1.3."
310- " Default value for mode with be 'min' in v1.3." , DeprecationWarning
311- )
312-
313- _condition = monitor is not None and ("acc" in monitor or monitor .startswith ("fmeasure" ))
314- mode_dict ['auto' ] = ((- torch_inf , "max" ) if _condition else (torch_inf , "min" ))
283+ if mode not in mode_dict :
284+ raise MisconfigurationException (f"`mode` can be { ', ' .join (mode_dict .keys ())} but got { mode } " )
315285
316286 self .kth_value , self .mode = mode_dict [mode ]
317287
@@ -410,7 +380,7 @@ def format_checkpoint_name(self, epoch: int, step: int, metrics: Dict[str, Any],
410380 'step=0.ckpt'
411381
412382 """
413- filename = self ._format_checkpoint_name (self .filename , epoch , step , metrics , prefix = self . prefix )
383+ filename = self ._format_checkpoint_name (self .filename , epoch , step , metrics )
414384 if ver is not None :
415385 filename = self .CHECKPOINT_JOIN_CHAR .join ((filename , f"v{ ver } " ))
416386
@@ -523,7 +493,6 @@ def _save_last_checkpoint(self, trainer, pl_module, ckpt_name_metrics):
523493 trainer .current_epoch ,
524494 trainer .global_step ,
525495 ckpt_name_metrics ,
526- prefix = self .prefix
527496 )
528497 last_filepath = os .path .join (self .dirpath , f"{ last_filepath } { self .FILE_EXTENSION } " )
529498 else :
0 commit comments