espnet2.train.trainer.TrainerOptions
espnet2.train.trainer.TrainerOptions
class espnet2.train.trainer.TrainerOptions(ngpu: int, resume: bool, use_amp: bool, train_dtype: str, grad_noise: bool, accum_grad: int, grad_clip: float, grad_clip_type: float, log_interval: int | None, no_forward_run: bool, use_matplotlib: bool, use_tensorboard: bool, use_wandb: bool, adapter: str, use_adapter: bool, save_strategy: str, output_dir: Path | str, max_epoch: int, seed: int, sharded_ddp: bool, patience: int | None, keep_nbest_models: int | List[int], nbest_averaging_interval: int, early_stopping_criterion: Sequence[str], best_model_criterion: Sequence[Sequence[str]], val_scheduler_criterion: Sequence[str], unused_parameters: bool, wandb_model_log_interval: int, create_graph_in_tensorboard: bool)
Bases: object
TrainerOptions is a data class that holds various options for training a model.
ngpu
Number of GPUs to use for training.
- Type: int
resume
Whether to resume training from a checkpoint.
- Type: bool
use_amp
Whether to use Automatic Mixed Precision.
- Type: bool
train_dtype
Data type used for training (e.g., ‘float32’).
- Type: str
grad_noise
Whether to apply gradient noise.
- Type: bool
accum_grad
Number of gradients to accumulate before updating.
- Type: int
grad_clip
Maximum norm for gradient clipping.
- Type: float
grad_clip
Type of norm for gradient clipping.
- Type: float
log_interval
Interval for logging training progress.
- Type: Optional[int]
no_forward_run
If True, skips the forward pass during training.
- Type: bool
use_matplotlib
Whether to use matplotlib for plotting.
- Type: bool
use_tensorboard
Whether to use TensorBoard for logging.
- Type: bool
use_wandb
Whether to use Weights and Biases for logging.
- Type: bool
adapter
Adapter type to use (e.g., ‘lora’).
- Type: str
use_adapter
Whether to use an adapter.
- Type: bool
save_strategy
Strategy for saving models (e.g., ‘all’).
- Type: str
output_dir
Directory to save outputs.
- Type: Union[Path, str]
max_epoch
Maximum number of training epochs.
- Type: int
seed
Random seed for reproducibility.
- Type: int
sharded_ddp
Whether to use sharded DDP.
- Type: bool
patience
Patience for early stopping.
- Type: Optional[int]
keep_nbest_models
Number of best models to keep.
- Type: Union[int, List[int]]
nbest_averaging_interval
Interval for averaging n-best models.
- Type: int
early_stopping_criterion
Criteria for early stopping.
- Type: Sequence[str]
best_model_criterion
Criteria for the best model.
- Type: Sequence[Sequence[str]]
val_scheduler_criterion
Validation scheduler criteria.
- Type: Sequence[str]
unused_parameters
Whether to allow unused parameters.
- Type: bool
wandb_model_log_interval
Interval for logging models to Weights and Biases.
- Type: int
create_graph_in_tensorboard
Whether to create computation graph in TensorBoard.
- Type: bool
Examples
>>> options = TrainerOptions(
... ngpu=1,
... resume=False,
... use_amp=True,
... train_dtype='float32',
... grad_noise=False,
... accum_grad=1,
... grad_clip=5.0,
... grad_clip_type=2,
... log_interval=10,
... no_forward_run=False,
... use_matplotlib=True,
... use_tensorboard=True,
... use_wandb=False,
... adapter='lora',
... use_adapter=True,
... save_strategy='all',
... output_dir='output/',
... max_epoch=100,
... seed=42,
... sharded_ddp=False,
... patience=10,
... keep_nbest_models=[1, 2],
... nbest_averaging_interval=5,
... early_stopping_criterion=['loss'],
... best_model_criterion=[['train', 'loss', 'min']],
... val_scheduler_criterion=['val_loss'],
... unused_parameters=False,
... wandb_model_log_interval=5,
... create_graph_in_tensorboard=True
... )
accum_grad
adapter
best_model_criterion
create_graph_in_tensorboard
early_stopping_criterion
grad_clip
grad_clip
grad_noise
keep_nbest_models
log_interval
max_epoch
nbest_averaging_interval
ngpu
no_forward_run
output_dir
patience
resume
save_strategy
seed
sharded_ddp
train_dtype
unused_parameters
use_adapter
use_amp
use_matplotlib
use_tensorboard
use_wandb
val_scheduler_criterion
wandb_model_log_interval