State

class plugins.train.model._base.state.State(model_dir: str, model_name: str, no_logs: bool)

Bases: object

Holds state information relating to the plugin’s saved model.

Parameters:
  • model_dir (str) – The full path to the model save location

  • model_name (str) – The name of the model plugin

  • no_logs (bool) – True if Tensorboard logs should not be generated, otherwise False

Attributes Summary

current_session

The state dictionary for the current session_id.

filename

Full path to the state filename

iterations

The total number of iterations that the model has trained.

lr_finder

The value discovered from the learning rate finder.

mixed_precision_layers

Layers that can be switched between mixed-float16 and float32.

model_needs_rebuild

True if mixed precision policy has changed so model needs to be rebuilt otherwise False

session_id

The current training session id.

sessions

The session information for each session in the state file

Methods Summary

add_lr_finder(learning_rate)

Add the optimal discovered learning rate from the learning rate finder

add_mixed_precision_layers(layers)

Add the list of model's layers that are compatible for mixed precision to the state dictionary

add_session_batchsize(batch_size)

Add the session batch size to the sessions dictionary.

increment_iterations()

Increment iterations and session iterations by 1.

save()

Save the state values to the serialized state file.

update_session_config(key, value)

Update a configuration item of the currently loaded session.

Attributes Documentation

current_session

The state dictionary for the current session_id.

Type:

dict

filename

Full path to the state filename

Type:

str

iterations

The total number of iterations that the model has trained.

Type:

int

lr_finder

The value discovered from the learning rate finder. -1 if no value stored

mixed_precision_layers

Layers that can be switched between mixed-float16 and float32.

Type:

list

model_needs_rebuild

True if mixed precision policy has changed so model needs to be rebuilt otherwise False

Type:

bool

session_id

The current training session id.

Type:

int

sessions

The session information for each session in the state file

Type:

dict[int, dict[str, Any]]

Methods Documentation

add_lr_finder(learning_rate: float) None

Add the optimal discovered learning rate from the learning rate finder

Parameters:

learning_rate (float) – The discovered learning rate

Return type:

None

add_mixed_precision_layers(layers: list[str]) None

Add the list of model’s layers that are compatible for mixed precision to the state dictionary

Parameters:

layers (list[str])

Return type:

None

add_session_batchsize(batch_size: int) None

Add the session batch size to the sessions dictionary.

Parameters:

batch_size (int) – The batch size for the current training session

Return type:

None

increment_iterations() None

Increment iterations and session iterations by 1.

Return type:

None

save() None

Save the state values to the serialized state file.

Return type:

None

update_session_config(key: str, value: Any) None

Update a configuration item of the currently loaded session.

Parameters:
  • key (str) – The configuration item to update for the current session

  • value (any) – The value to update to

Return type:

None

add_lr_finder(learning_rate: float) None

Add the optimal discovered learning rate from the learning rate finder

Parameters:

learning_rate (float) – The discovered learning rate

Return type:

None

add_mixed_precision_layers(layers: list[str]) None

Add the list of model’s layers that are compatible for mixed precision to the state dictionary

Parameters:

layers (list[str])

Return type:

None

add_session_batchsize(batch_size: int) None

Add the session batch size to the sessions dictionary.

Parameters:

batch_size (int) – The batch size for the current training session

Return type:

None

property current_session: dict

The state dictionary for the current session_id.

Type:

dict

property filename: str

Full path to the state filename

Type:

str

increment_iterations() None

Increment iterations and session iterations by 1.

Return type:

None

property iterations: int

The total number of iterations that the model has trained.

Type:

int

lowest_avg_loss: float

The lowest average loss seen between save intervals.

Type:

float

property lr_finder: float

The value discovered from the learning rate finder. -1 if no value stored

property mixed_precision_layers: list[str]

Layers that can be switched between mixed-float16 and float32.

Type:

list

property model_needs_rebuild: bool

True if mixed precision policy has changed so model needs to be rebuilt otherwise False

Type:

bool

save() None

Save the state values to the serialized state file.

Return type:

None

property session_id: int

The current training session id.

Type:

int

property sessions: dict[int, dict[str, Any]]

The session information for each session in the state file

Type:

dict[int, dict[str, Any]]

update_session_config(key: str, value: Any) None

Update a configuration item of the currently loaded session.

Parameters:
  • key (str) – The configuration item to update for the current session

  • value (any) – The value to update to

Return type:

None