noether.core.utils.training¶
Submodules¶
Classes¶
UpdateCounter is used to track the current update, epoch, and sample |
|
Wrapper around a schedule that handles getting the value based on an UpdateCounter and whether the schedule is |
|
Package Contents¶
- class noether.core.utils.training.UpdateCounter(start_iteration, end_iteration, updates_per_epoch, effective_batch_size)¶
UpdateCounter is used to track the current update, epoch, and sample number during training.
Initializes UpdateCounter.
- Parameters:
start_iteration (noether.core.utils.training.training_iteration.TrainingIteration) – The iteration (measured in either epochs, updates, or samples) at which the training will start. If the training is resumed the values will be updated accordingly.
end_iteration (noether.core.utils.training.training_iteration.TrainingIteration) – The iteration (measured in either epochs, updates, or samples) at which the training will end.
updates_per_epoch (int) – Number of updates per epoch.
effective_batch_size (int) – Effective batch size.
- updates_per_epoch¶
- start_iteration¶
- end_iteration¶
- cur_iteration¶
- effective_batch_size¶
- next_epoch()¶
Increments the current epoch by 1.
- Return type:
None
- next_update()¶
Increments the current update by 1.
- Return type:
None
- class noether.core.utils.training.ScheduleWrapper(schedule, update_counter=None, interval='update')¶
Wrapper around a schedule that handles getting the value based on an UpdateCounter and whether the schedule is based on updates or epochs.
- Parameters:
schedule (noether.core.schedules.ScheduleBase) – The
ScheduleBaseto wrap.update_counter (noether.core.utils.training.counter.UpdateCounter | None) – The
UpdateCounterto use for getting the current step. If None, the schedule is assumed to be constant.interval (Literal['update', 'epoch']) – Whether the schedule is based on updates or epochs. Interval should be either “update” or “epoch”.
- schedule¶
- update_counter = None¶
- interval = 'update'¶
- class noether.core.utils.training.TrainingIteration(epoch=None, update=None, sample=None)¶
-
- epoch = None¶
- update = None¶
- sample = None¶
- copy()¶
Creates a copy of a TrainingIteration object.
- Return type:
- property specified_properties_count: int¶
Counts the number of specified (non-None) properties.
- Return type:
- get_n_equal_properties(other)¶
Counts the number of equal properties between two TrainingIteration objects.
- Parameters:
other (TrainingIteration) – The other TrainingIteration object to compare with.
- Return type:
- to_fully_specified(updates_per_epoch, effective_batch_size)¶
Converts the TrainingIteration object to a fully specified TrainingIteration object. This method calculates the missing properties based on the specified ones.
- Parameters:
- Return type:
- classmethod from_dict(data)¶
- Parameters:
- Return type:
- has_same_specified_properties(other)¶
Checks if the specified properties of two TrainingIteration objects are the same.
- Parameters:
other (TrainingIteration) – The other TrainingIteration object to compare with.
- Return type:
- static from_string(value)¶
Converts a training iteration string into a TrainingIteration object.
The training iteration string should be in the format “E{epoch}_U{update}_S{sample}”. For instance: E5_U12_S123 corresponds to TrainingIteration(epoch=5, update=12, sample=123).
- Parameters:
value (str) – The TrainingIteration string to convert.
- Return type:
- static contains_string(source)¶
Checks if the source string contains a training iteration string.
- static find_string(source)¶
Checks if the source string contains a training iteration string and returns it.
- static from_filename(fname)¶
Creates a TrainingIteration object from a filename that contains a training iteration string.
- Parameters:
fname (str) – The filename to extract the training iteration string from.
- Returns:
The created object.
- Return type:
- static to_fully_specified_from_filenames(directory, training_iteration, prefix=None, suffix=None)¶
Converts a minimally specified TrainingIteration to a fully specified one from filenames in a given folder. The first file containing a training iteration string and optionally starting with prefix or ending with suffix is used.
- Parameters:
directory (str) – The directory containing training iteration files.
training_iteration (TrainingIteration) – The TrainingIteration object to match against.
prefix (str | None) – Optional prefix to filter files.
suffix (str | None) – Optional suffix to filter files.
- Returns:
The created object.
- Return type:
- Raises:
FileNotFoundError – If no matching file is found.
- to_target_specification(target)¶
Creates a new object that matches the target specification.
Example:
` self=TrainingIteration(epoch=6, update=12, sample=123)` target=TrainingIteration(epoch=5) print(self.to_target_specification(target)) TrainingIteration(epoch=6) `:param target: The target TrainingIteration object to match against.- Returns:
The created object.
- Return type:
- Parameters:
target (TrainingIteration)