class_docstr: Class to bind an optimizer, model, strategy, and training step function.
class_docstr_tok: ["Class","to","bind","an","optimizer",",","model",",","strategy",",","and","training","step","function","."]
docstr: Constructor.
  
  Args:
    model: Model to train.
    strategy: A distribution strategy.
    checkpoints_to_keep: Max number of checkpoints before deleting oldest.
    learning_rate: Scalar initial learning rate.
    lr_decay_steps: Exponential decay timescale.
    lr_decay_rate: Exponential decay magnitude.
    grad_clip_norm: Norm level by which to clip gradients.
    restore_keys: List of names of model properties to restore. If no keys are
      passed, restore the whole model.
docstr_tok: ["Constructor",".","Args",":","model",":","Model","to","train",".","strategy",":","A","distribution","strategy",".","checkpoints_to_keep",":","Max","number","of","checkpoints","before","deleting","oldest",".","learning_rate",":","Scalar","initial","learning","rate",".","lr_decay_steps",":","Exponential","decay","timescale",".","lr_decay_rate",":","Exponential","decay","magnitude",".","grad_clip_norm",":","Norm","level","by","which","to","clip","gradients",".","restore_keys",":","List","of","names","of","model","properties","to","restore",".","If","no","keys","are","passed",",","restore","the","whole","model","."]
code: def __init__(
      self,
      model,
      strategy,
      checkpoints_to_keep=100,
      learning_rate=0.001,
      lr_decay_steps=10000,
      lr_decay_rate=0.98,
      grad_clip_norm=3.0,
      restore_keys=None,
  ):
      """Constructor.
  
      Args:
        model: Model to train.
        strategy: A distribution strategy.
        checkpoints_to_keep: Max number of checkpoints before deleting oldest.
        learning_rate: Scalar initial learning rate.
        lr_decay_steps: Exponential decay timescale.
        lr_decay_rate: Exponential decay magnitude.
        grad_clip_norm: Norm level by which to clip gradients.
        restore_keys: List of names of model properties to restore. If no keys are
          passed, restore the whole model.
      """
      self.model = model
      self.strategy = strategy
      self.checkpoints_to_keep = checkpoints_to_keep
      self.grad_clip_norm = grad_clip_norm
      self.restore_keys = restore_keys
  
      # Create an optimizer.
      lr_schedule = tf.keras.optimizers.schedules.ExponentialDecay(
          initial_learning_rate=learning_rate,
          decay_steps=lr_decay_steps,
          decay_rate=lr_decay_rate,
      )
  
      with self.strategy.scope():
          self.optimizer = tf.keras.optimizers.Adam(lr_schedule)
  
file_path: ddsp/ddsp/training/trainers.py
imports: import time
  from absl import logging
  from ddsp.training import train_util
  import gin
  import tensorflow.compat.v2
label_desc: Use image node_id 1 to create a new Trainer object from inherited base classes: object with example: obj = Trainer(model, strategy, checkpoints_to_keep, learning_rate, lr_decay_steps, lr_decay_rate, grad_clip_norm, restore_keys)