Train
ExperimentParams
Bases: dict
Container for experiment parameters
Source code in src/trecover/utils/train.py
jsonify
Simplify experiment parameters for further json serialization.
Returns:
Type | Description |
---|---|
Experiment parameters as a dictionary with python built-in types values.
|
Source code in src/trecover/utils/train.py
set_seeds
Set seeds for experiment reproducibility
get_experiment_params
Parse command line arguments as ExperimentParams object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
ArgumentParser
|
Object for parsing command line strings into Python objects. |
required |
args |
Optional[List[str]], default
|
Command line arguments. |
None
|
Returns:
Name | Type | Description |
---|---|---|
ExperimentParams |
ExperimentParams
|
Parsed command line arguments as ExperimentParams object. |
Source code in src/trecover/utils/train.py
load_params
Get experiment parameters container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_params |
Path
|
Path to serialized experiment parameters. |
required |
Returns:
Name | Type | Description |
---|---|---|
ExperimentParams |
ExperimentParams
|
Experiment parameters container as a ExperimentParams object. |
Source code in src/trecover/utils/train.py
save_params
Save experiment parameters on disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Dict
|
Experiment parameters. |
required |
filepath |
Path
|
File path for saving. |
required |
sort |
bool, default
|
Perform parameters keys sorting. |
False
|
Source code in src/trecover/utils/train.py
get_experiment_mark
optimizer_to_str
Get optimizer object string representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimizer |
Optimizer
|
Optimizer object for representation. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Optimizer string representation. |
Source code in src/trecover/utils/train.py
transfer
Transfer the tensors to a specified device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tensors |
Tuple
|
Sequence of tensors to transfer. |
required |
to_device |
torch.device
|
The desired device of returned tensors. |
required |
Returns:
Type | Description |
---|---|
Tuple[Optional[Tensor], ...]
|
Tuple of tensors allocated on the specified device. |