Skip to content

Commit

Permalink
Merge pull request #680 from mv1388/docs_improvement
Browse files Browse the repository at this point in the history
Docs improvement
  • Loading branch information
mv1388 committed Jul 8, 2022
2 parents dbc95d2 + 45c3c9f commit f2f55d1
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions aitoolbox/experiment/experiment_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def save_experiment(self, model, result_package, training_history, experiment_ti
training_history (aitoolbox.experiment.training_history.TrainingHistory):
experiment_timestamp (str): time stamp of the training start
save_true_pred_labels (bool): should ground truth labels also be saved
separate_files (bool): should the results be saved in separate pickle files or should all of the results
separate_files (bool): should the results be saved in separate pickle files or should all the results
be batched together in a single results file
protect_existing_folder (bool): can override potentially already existing folder or not
Expand Down Expand Up @@ -60,7 +60,7 @@ def save_experiment(self, model, result_package, training_history, experiment_ti
training_history (aitoolbox.experiment.training_history.TrainingHistory):
experiment_timestamp (str): time stamp at the start of training
save_true_pred_labels (bool): should ground truth labels also be saved
separate_files (bool): should the results be saved in separate pickle files or should all of the results
separate_files (bool): should the results be saved in separate pickle files or should all the results
be batched together in a single results file
protect_existing_folder (bool): can override potentially already existing folder or not
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/experiment/local_experiment_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def save_experiment(self, model, result_package, training_history, experiment_ti
training_history (aitoolbox.experiment.training_history.TrainingHistory):
experiment_timestamp (str): time stamp at the start of training
save_true_pred_labels (bool): should ground truth labels also be saved
separate_files (bool): should the results be saved in separate pickle files or should all of the results
separate_files (bool): should the results be saved in separate pickle files or should all the results
be batched together in a single results file
protect_existing_folder (bool): can override potentially already existing folder or not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, pkg_name=None, strict_content_check=False, np_array=True, **k
Args:
pkg_name (str or None): result package name used just for clarity
strict_content_check (bool): should just print warning or raise the error and crash
np_array (bool or str): how the inputs should be handled. Should the package try to automatically guess or
np_array (bool or str): how the inputs should be handled. Should the package try to automatically guess, or
you want to manually decide whether to leave the inputs as they are or convert them to np.array.
Possible options: True, False, 'auto'
Be slightly careful with 'auto' as it sometimes doesn't work so it is preferable to explicitly use True/False
Expand Down Expand Up @@ -151,9 +151,9 @@ def get_additional_results_dump_paths(self):
return self.additional_results_dump_paths

def list_additional_results_dump_paths(self):
"""Specify the list of meta data files you also want to save & upload to s3 during the experiment saving procedure
"""Specify the list of metadata files you also want to save & upload to s3 during the experiment saving procedure
By default there are no additional files that are saved as the return is None. If you want to save your
By default, there are no additional files that are saved as the return is None. If you want to save your
specific additional files produced during the training procedure, then override this method specifying
the file paths.
Expand Down
4 changes: 3 additions & 1 deletion aitoolbox/experiment/result_reporting/hyperparam_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def copy_to_cloud_storage(self, local_hyperparams_file_path, cloud_saver, file_n
"""Copy saved text local file into cloud storage
Args:
local_hyperparams_file_path (str): path to hyperparams file stored on local disk. File to be uploaded to cloud
local_hyperparams_file_path (str): path to hyperparams file stored on local disk.
File to be uploaded to cloud
cloud_saver (BaseModelSaver or BaseResultsSaver or BaseModelGoogleStorageSaver or BaseResultsGoogleStorageSaver):
cloud saver object
file_name (str or None): manually specify the file name to be saved to the cloud instead of taking
the default from self.file_name
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/experiment/result_reporting/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def generate_report(self, training_history, epoch, file_name, results_folder_nam
epoch (int): current epoch
file_name (str): output text file name
results_folder_name (str): results folder path where the report file will be located
file_format (str): output file format. Can be either 'txt' human readable output or
file_format (str): output file format. Can be either 'txt' human-readable output or
'tsv' for a tabular format or 'csv' for comma separated format.
Returns:
Expand Down
4 changes: 2 additions & 2 deletions aitoolbox/torchtrain/callbacks/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def on_after_gradient_update(self, optimizer_idx):
"""Logic executed after the model gradients are updated
To ensure the execution of this callback enable the `self.train_loop_obj.grad_cb_used = True` option in the
on_train_loop_registration(). Otherwise logic implemented here will not be executed by the TrainLoop.
on_train_loop_registration(). Otherwise, logic implemented here will not be executed by the TrainLoop.
Args:
optimizer_idx (int): index of the current optimizer. Mostly useful when using multiple optimizers.
Expand All @@ -118,7 +118,7 @@ def on_after_optimizer_step(self):
"""Logic executed after the optimizer does a new step and updates the model weights
To ensure the execution of this callback enable the `self.train_loop_obj.grad_cb_used = True` option in the
on_train_loop_registration(). Otherwise logic implemented here will not be executed by the TrainLoop.
on_train_loop_registration(). Otherwise, logic implemented here will not be executed by the TrainLoop.
Returns:
None
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/torchtrain/callbacks/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def __init__(self, fn_to_execute,
after_gradient_update (bool): should execute after the gradient update
after_optimizer_step (bool): should execute after the optimizer step
execution_order (int): order of the callback execution. If all the used callbacks have the orders set to 0,
than the callbacks are executed in the order they were registered.
then the callbacks are executed in the order they were registered.
"""
AbstractCallback.__init__(self, 'Execute given function as a callback', execution_order, device_idx_execution)
self.fn_to_execute = fn_to_execute
Expand Down
6 changes: 3 additions & 3 deletions aitoolbox/torchtrain/callbacks/gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class GradientCallbackBase(AbstractCallback):
def __init__(self, callback_name, execution_order=0):
"""Base abstract class for gradient related callbacks
It has not implemented logic except for the the turning enabling of the grad_cb_used inside TrainLoop as part of
It has not implemented logic except for the turning enabling of the grad_cb_used inside TrainLoop as part of
the on_train_loop_registration(). Consequently, this potentially repeated task in every gradient calculation
callback doesn't need to be done for every implemented callback.
Args:
callback_name (str): name of the callback
execution_order (int): order of the callback execution. If all the used callbacks have the orders set to 0,
than the callbacks are executed in the order they were registered.
then the callbacks are executed in the order they were registered.
"""
AbstractCallback.__init__(self, callback_name, execution_order)

Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(self, max_grad_norm, **kwargs):
Args:
max_grad_norm (int or float): max norm of the gradients
**kwargs: torch.nn.utils.clip_grad_norm_ additional arguemnts
**kwargs: torch.nn.utils.clip_grad_norm_ additional arguments
"""
GradientCallbackBase.__init__(self, 'Gradient norm clipping')
self.max_grad_norm = max_grad_norm
Expand Down
6 changes: 3 additions & 3 deletions aitoolbox/torchtrain/callbacks/performance_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, metrics, on_each_epoch=True, report_frequency=None,
"""Print the model performance to the console
Best used in combination with the callback which actually calculates some performance evaluation metrics, such
as ModelPerformanceEvaluation. Otherwise we are limited only to automatic loss calculation reporting.
as ModelPerformanceEvaluation. Otherwise, we are limited only to automatic loss calculation reporting.
When listing callbacks for the TrainLoop it is important to list the ModelPerformanceEvaluation before
this ModelPerformancePrintReport. This ensures that the calculated results are present in the
Expand Down Expand Up @@ -309,7 +309,7 @@ def __init__(self, callback_name, execution_order=0,
Args:
callback_name (str): name of the callback
execution_order (int): order of the callback execution. If all the used callbacks have the orders set to 0,
than the callbacks are executed in the order they were registered.
then the callbacks are executed in the order they were registered.
epoch_end (bool): should plot after every epoch
train_end (bool): should plot at the end of the training
file_format (str): output file format
Expand Down Expand Up @@ -443,7 +443,7 @@ def __init__(self, epoch_end=True, train_end=False, file_format='txt',
Args:
epoch_end (bool): should plot after every epoch
train_end (bool): should plot at the end of the training
file_format (str): output file format. Can be either 'txt' human readable output or
file_format (str): output file format. Can be either 'txt' human-readable output or
'tsv' for a tabular format or 'csv' for comma separated format.
project_name (str or None): root name of the project
experiment_name (str or None): name of the particular experiment
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/torchtrain/data/batch_model_feed_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbstractModelFeedDefinition(ABC):
The primary way of defining the model for TrainLoop training is to utilize:
aitoolbox.torchtrain.model.TTModel
Use of the ModelFeedDefinition is the legacy way of defining the model. However in certain scenarios where the
Use of the ModelFeedDefinition is the legacy way of defining the model. However, in certain scenarios where the
TTModel might prove to increase complexity, ModelFeedDefinition still is useful for augmenting the nn.Module with
the logic to calculate loss and predictions.
"""
Expand Down
4 changes: 2 additions & 2 deletions aitoolbox/torchtrain/multi_loss_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def backward(self, optimizer_idx, iteration, amp_grad_scaler):
iteration (int): Current iteration index. Not used in the most simple setup but provided in case of more
elaborate loss backward logic is devised.
amp_grad_scaler (torch.cuda.amp.GradScaler): AMP GradScaler. If scaler ``enabled`` parameter is set to False
the loss is still passed to it but it gets returned unscaled so the behaviour is as it is in the case
the loss is still passed to it, but it gets returned unscaled so the behaviour is as it is in the case
of non-AMP training.
Returns:
Expand Down Expand Up @@ -79,7 +79,7 @@ def step(self, optimizer_idx, iteration, amp_grad_scaler):
iteration (int): Current iteration index. Not used in the most simple setup but provided in case of more
elaborate loss backward logic is devised.
amp_grad_scaler (torch.cuda.amp.GradScaler): AMP GradScaler. If scaler ``enabled`` parameter is set to False
the optimizer have it's normal step() method called withoud applying the AMP mandated unscaling
the optimizer have it's normal step() method called without applying the AMP mandated unscaling
beforehand. In this respect the behaviour will be the same as in the non-AMP training.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/torchtrain/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, module,
default_model_methods=('get_loss', 'get_loss_eval', 'get_predictions'), **kwargs):
"""torchtrain enabled DataParallel
This DataParallel wrapper works in the same way as the original PyTorch nn.DataParallel. Furthermore it exposes
This DataParallel wrapper works in the same way as the original PyTorch nn.DataParallel. Furthermore, it exposes
TTModel batch data feeding definitions (additional abstract methods) to the TrainLoop while still enabling
multi GPU training.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, train_loop_obj):
def register_callbacks(self, callbacks, cache_callbacks=False):
"""Register TrainLoop object reference inside the listed callbacks when the TrainLoop is created
Normally, this is called from inside of the train loop by the TrainLoop itself. Basically train loop "registers"
Normally, this is called from inside the train loop by the TrainLoop itself. Basically train loop "registers"
itself.
Args:
Expand Down
2 changes: 1 addition & 1 deletion aitoolbox/torchtrain/train_loop/train_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def _spawn_fit(self, gpu, ddp_args, num_epochs, num_iterations, callbacks, grad_
grad_accumulation (int): number of batches the gradients are accumulated before updating weights
in_process_data_load (list or None): in-process data loading logic implemented as a torchtrain callback.
The logic should be placed inside the on_multiprocess_start() callback function.
When using this data loading option bare in mind that loaded dataset will be replicated in memory for
When using this data loading option bear in mind that loaded dataset will be replicated in memory for
every spawned training process. This can in turn in cause extensive overall memory consumption.
"""
rank = ddp_args['node_rank'] * ddp_args['num_gpus'] + gpu
Expand Down

0 comments on commit f2f55d1

Please sign in to comment.