@@ -65,92 +65,92 @@ def remove(self, filename: str) -> None:
6565
6666class Checkpoint (Serializable ):
6767 """Checkpoint handler can be used to periodically save and load objects which have attribute
68- `` state_dict`/`load_state_dict` `. This class can use specific save handlers to store on the disk or a cloud
68+ `state_dict`/`load_state_dict`. This class can use specific save handlers to store on the disk or a cloud
6969 storage, etc. The Checkpoint handler (if used with :class:`~ignite.handlers.DiskSaver`) also handles automatically
7070 moving data on TPU to CPU before writing the checkpoint.
7171
7272 Args:
73- to_save (Mapping): Dictionary with the objects to save. Objects should have implemented `` state_dict` ` and
74- `` load_state_dict` ` methods. If contains objects of type torch `DistributedDataParallel`_ or
75- `DataParallel`_, their internal wrapped model is automatically saved (to avoid additional key `` module.` ` in
73+ to_save (Mapping): Dictionary with the objects to save. Objects should have implemented `state_dict` and
74+ `load_state_dict` methods. If contains objects of type torch `DistributedDataParallel`_ or
75+ `DataParallel`_, their internal wrapped model is automatically saved (to avoid additional key `module.` in
7676 the state dictionary).
7777 save_handler (callable or :class:`~ignite.handlers.checkpoint.BaseSaveHandler`): Method or callable class to
7878 use to save engine and other provided objects. Function receives two objects: checkpoint as a dictionary
79- and filename. If `` save_handler` ` is callable class, it can
80- inherit of :class:`~ignite.handlers.checkpoint.BaseSaveHandler` and optionally implement `` remove` ` method
79+ and filename. If `save_handler` is callable class, it can
80+ inherit of :class:`~ignite.handlers.checkpoint.BaseSaveHandler` and optionally implement `remove` method
8181 to keep a fixed number of saved checkpoints. In case if user needs to save engine's checkpoint on a disk,
82- `` save_handler` ` can be defined with :class:`~ignite.handlers.DiskSaver`.
82+ `save_handler` can be defined with :class:`~ignite.handlers.DiskSaver`.
8383 filename_prefix (str, optional): Prefix for the file name to which objects will be saved. See Note for details.
8484 score_function (callable, optional): If not None, it should be a function taking a single argument,
8585 :class:`~ignite.engine.engine.Engine` object, and returning a score (`float`). Objects with highest scores
8686 will be retained.
87- score_name (str, optional): If `` score_function` ` not None, it is possible to store its value using
88- `` score_name` `. See Notes for more details.
87+ score_name (str, optional): If `score_function` not None, it is possible to store its value using
88+ `score_name`. See Notes for more details.
8989 n_saved (int, optional): Number of objects that should be kept on disk. Older files will be removed. If set to
9090 `None`, all objects are kept.
9191 global_step_transform (callable, optional): global step transform function to output a desired global step.
92- Input of the function is `` (engine, event_name)` `. Output of function should be an integer.
92+ Input of the function is `(engine, event_name)`. Output of function should be an integer.
9393 Default is None, global_step based on attached engine. If provided, uses function output as global_step.
9494 To setup global step from another engine, please use :meth:`~ignite.handlers.global_step_from_engine`.
95- archived (bool, optional): Deprecated argument as models saved by `` torch.save` ` are already compressed.
96- filename_pattern (str, optional): If `` filename_pattern` ` is provided, this pattern will be used to render
95+ archived (bool, optional): Deprecated argument as models saved by `torch.save` are already compressed.
96+ filename_pattern (str, optional): If `filename_pattern` is provided, this pattern will be used to render
9797 checkpoint filenames. If the pattern is not defined, the default pattern would be used. See Note for
9898 details.
9999 include_self (bool): Whether to include the `state_dict` of this object in the checkpoint. If `True`, then
100- there must not be another object in `` to_save`` with key `` checkpointer` `.
100+ there must not be another object in `to_save` with key `checkpointer`.
101101
102102 .. _DistributedDataParallel: https://pytorch.org/docs/stable/nn.html#torch.nn.parallel.DistributedDataParallel
103103 .. _DataParallel: https://pytorch.org/docs/stable/nn.html#torch.nn.DataParallel
104104
105105 Note:
106106 This class stores a single file as a dictionary of provided objects to save.
107- The filename is defined by `` filename_pattern` ` and by default has the following
108- structure: `` {filename_prefix}_{name}_{suffix}.{ext}` ` where
107+ The filename is defined by `filename_pattern` and by default has the following
108+ structure: `{filename_prefix}_{name}_{suffix}.{ext}` where
109109
110- - `` filename_prefix` ` is the argument passed to the constructor,
111- - `name` is the key in `` to_save` ` if a single object is to store, otherwise `name` is "checkpoint".
112- - `suffix` is composed as following `` {global_step}_{score_name}={score}` `.
110+ - `filename_prefix` is the argument passed to the constructor,
111+ - `name` is the key in `to_save` if a single object is to store, otherwise `name` is "checkpoint".
112+ - `suffix` is composed as following `{global_step}_{score_name}={score}`.
113113
114114 +----------------+------------+-----------------------+----------------------------------------------+
115115 | score_function | score_name | global_step_transform | suffix |
116116 +================+============+=======================+==============================================+
117- | None | None | None | `` {engine.state.iteration}` ` |
117+ | None | None | None | `{engine.state.iteration}` |
118118 +----------------+------------+-----------------------+----------------------------------------------+
119- | X | None | None | `` {score}` ` |
119+ | X | None | None | `{score}` |
120120 +----------------+------------+-----------------------+----------------------------------------------+
121- | X | None | X | `` {global_step}_{score}` ` |
121+ | X | None | X | `{global_step}_{score}` |
122122 +----------------+------------+-----------------------+----------------------------------------------+
123- | X | X | X | `` {global_step}_{score_name}={score}` ` |
123+ | X | X | X | `{global_step}_{score_name}={score}` |
124124 +----------------+------------+-----------------------+----------------------------------------------+
125- | None | None | X | `` {global_step}` ` |
125+ | None | None | X | `{global_step}` |
126126 +----------------+------------+-----------------------+----------------------------------------------+
127- | X | X | None | `` {score_name}={score}` ` |
127+ | X | X | None | `{score_name}={score}` |
128128 +----------------+------------+-----------------------+----------------------------------------------+
129129
130130 Above `global_step` defined by the output of `global_step_transform` and `score` defined by the output
131131 of `score_function`.
132132
133- By default, none of `` score_function`` , `` score_name`` , `` global_step_transform` ` is defined, then suffix is
133+ By default, none of `score_function`, `score_name`, `global_step_transform` is defined, then suffix is
134134 setup by attached engine's current iteration. The filename will be
135135 `{filename_prefix}_{name}_{engine.state.iteration}.{ext}`.
136136
137- For example, `` score_name="neg_val_loss"`` and `` score_function` ` that returns `-loss` (as objects with highest
138- scores will be retained), then saved filename will be `` {filename_prefix}_{name}_neg_val_loss=-0.1234.pt` `.
137+ For example, `score_name="neg_val_loss"` and `score_function` that returns `-loss` (as objects with highest
138+ scores will be retained), then saved filename will be `{filename_prefix}_{name}_neg_val_loss=-0.1234.pt`.
139139
140140 Note:
141- If `` filename_pattern`` is given, it will be used to render the filenames. `` filename_pattern` ` is a string
142- that can contain `` {filename_prefix}`` , `` {name}`` , `` {score}`` , `` {score_name}`` and `` {global_step}` ` as
141+ If `filename_pattern` is given, it will be used to render the filenames. `filename_pattern` is a string
142+ that can contain `{filename_prefix}`, `{name}`, `{score}`, `{score_name}` and `{global_step}` as
143143 templates.
144144
145- For example, let `` filename_pattern="{global_step}-{name}-{score}.pt"` ` then the saved filename will be
146- `` 30000-checkpoint-94.pt` `
145+ For example, let `filename_pattern="{global_step}-{name}-{score}.pt"` then the saved filename will be
146+ `30000-checkpoint-94.pt`
147147
148148 **Warning:** Please, keep in mind that if filename collide with already used one to saved a checkpoint,
149- new checkpoint will not be stored. This means that filename like `` checkpoint.pt` ` will be saved only once
149+ new checkpoint will not be stored. This means that filename like `checkpoint.pt` will be saved only once
150150 and will not be overwritten by newer checkpoints.
151151
152152 Note:
153- To get the last stored filename, handler exposes attribute `` last_checkpoint` `:
153+ To get the last stored filename, handler exposes attribute `last_checkpoint`:
154154
155155 .. code-block:: python
156156
@@ -390,16 +390,16 @@ def setup_filename_pattern(
390390 """Helper method to get the default filename pattern for a checkpoint.
391391
392392 Args:
393- with_prefix (bool): If True, the `` filename_prefix` ` is added to the filename pattern:
394- `` {filename_prefix}_{name}...` `. Default, True.
395- with_score (bool): If True, `` score`` is added to the filename pattern: `` ..._{score}.{ext}` `.
396- Default, True. At least one of `` with_score`` and `` with_global_step` ` should be True.
397- with_score_name (bool): If True, `` score_name` ` is added to the filename pattern:
398- `` ..._{score_name}={score}.{ext}`` . If activated, argument `` with_score` ` should be
393+ with_prefix (bool): If True, the `filename_prefix` is added to the filename pattern:
394+ `{filename_prefix}_{name}...`. Default, True.
395+ with_score (bool): If True, `score` is added to the filename pattern: `..._{score}.{ext}`.
396+ Default, True. At least one of `with_score` and `with_global_step` should be True.
397+ with_score_name (bool): If True, `score_name` is added to the filename pattern:
398+ `..._{score_name}={score}.{ext}`. If activated, argument `with_score` should be
399399 also True, otherwise an error is raised. Default, True.
400- with_global_step (bool): If True, `` {global_step}` ` is added to the
401- filename pattern: `` ...{name}_{global_step}...` `.
402- At least one of `` with_score`` and `` with_global_step` ` should be True.
400+ with_global_step (bool): If True, `{global_step}` is added to the
401+ filename pattern: `...{name}_{global_step}...`.
402+ At least one of `with_score` and `with_global_step` should be True.
403403
404404 Example:
405405
@@ -441,7 +441,7 @@ def _check_objects(objs: Mapping, attr: str) -> None:
441441
442442 @staticmethod
443443 def load_objects (to_load : Mapping , checkpoint : Mapping , ** kwargs ) -> None :
444- """Helper method to apply `` load_state_dict`` on the objects from `` to_load`` using states from `` checkpoint` `.
444+ """Helper method to apply `load_state_dict` on the objects from `to_load` using states from `checkpoint`.
445445
446446 Exemples:
447447
@@ -464,8 +464,8 @@ def load_objects(to_load: Mapping, checkpoint: Mapping, **kwargs) -> None:
464464 Checkpoint.load_objects(to_load=to_load, checkpoint=checkpoint)
465465
466466 Note:
467- If `` to_load` ` contains objects of type torch `DistributedDataParallel`_ or
468- `DataParallel`_, method `` load_state_dict`` will applied to their internal wrapped model (`` obj.module` `).
467+ If `to_load` contains objects of type torch `DistributedDataParallel`_ or
468+ `DataParallel`_, method `load_state_dict` will applied to their internal wrapped model (`obj.module`).
469469
470470 Args:
471471 to_load (Mapping): a dictionary with objects, e.g. `{"model": model, "optimizer": optimizer, ...}`
@@ -523,9 +523,9 @@ class DiskSaver(BaseSaveHandler):
523523 atomic (bool, optional): if True, checkpoint is serialized to a temporary file, and then
524524 moved to final destination, so that files are guaranteed to not be damaged
525525 (for example if exception occurs during saving).
526- create_dir (bool, optional): if True, will create directory `` dirname` ` if it doesnt exist.
526+ create_dir (bool, optional): if True, will create directory `dirname` if it doesnt exist.
527527 require_empty (bool, optional): If True, will raise exception if there are any files in the
528- directory `` dirname` `.
528+ directory `dirname`.
529529 """
530530
531531 def __init__ (
@@ -617,9 +617,9 @@ class ModelCheckpoint(Checkpoint):
617617
618618 Behaviour of this class has been changed since v0.3.0.
619619
620- Argument `` save_as_state_dict` ` is deprecated and should not be used. It is considered as True.
620+ Argument `save_as_state_dict` is deprecated and should not be used. It is considered as True.
621621
622- Argument `` save_interval` ` is deprecated and should not be used. Please, use events filtering instead, e.g.
622+ Argument `save_interval` is deprecated and should not be used. Please, use events filtering instead, e.g.
623623 :attr:`~ignite.engine.events.Events.ITERATION_STARTED(every=1000)`
624624
625625 There is no more internal counter that has been used to indicate the number of save actions. User could
@@ -636,23 +636,23 @@ class ModelCheckpoint(Checkpoint):
636636 score_function (callable, optional): if not None, it should be a function taking a single argument, an
637637 :class:`~ignite.engine.engine.Engine` object, and return a score (`float`). Objects with highest scores
638638 will be retained.
639- score_name (str, optional): if `` score_function` ` not None, it is possible to store its value using
639+ score_name (str, optional): if `score_function` not None, it is possible to store its value using
640640 `score_name`. See Notes for more details.
641641 n_saved (int, optional): Number of objects that should be kept on disk. Older files will be removed. If set to
642642 `None`, all objects are kept.
643643 atomic (bool, optional): If True, objects are serialized to a temporary file, and then moved to final
644644 destination, so that files are guaranteed to not be damaged (for example if exception
645645 occurs during saving).
646646 require_empty (bool, optional): If True, will raise exception if there are any files starting with
647- `` filename_prefix`` in the directory `` dirname` `.
648- create_dir (bool, optional): If True, will create directory `` dirname` ` if it does not exist.
647+ `filename_prefix` in the directory `dirname`.
648+ create_dir (bool, optional): If True, will create directory `dirname` if it does not exist.
649649 global_step_transform (callable, optional): global step transform function to output a desired global step.
650650 Input of the function is `(engine, event_name)`. Output of function should be an integer.
651651 Default is None, global_step based on attached engine. If provided, uses function output as global_step.
652652 To setup global step from another engine, please use :meth:`~ignite.handlers.global_step_from_engine`.
653653 archived (bool, optional): Deprecated argument as models saved by `torch.save` are already compressed.
654654 include_self (bool): Whether to include the `state_dict` of this object in the checkpoint. If `True`, then
655- there must not be another object in `` to_save`` with key `` checkpointer` `.
655+ there must not be another object in `to_save` with key `checkpointer`.
656656
657657 Examples:
658658 >>> import os
0 commit comments