Optimizer

class hy2dl.training.optimizer.Optimizer(cfg: Config, model: Module)

Bases: object

Manage the optimizer.

Parameters:
  • cfg (Config) – Configuration file.

  • model – Model to be optimized

clip_grad_and_step(epoch: int, batch: int) None

Perform an optimization step.

Before performing a step with the optimizer, tries to clip the gradients with a maximum norm of 1.

Parameters:
  • epoch (int) – Current epoch

  • batch (int) – Batch ID of the current batch

update_optimizer_lr(epoch: int)

Update the learning rate

Parameters:

epoch (int) – Current epoch