class_docstr: ## Base class for *Adam* and extensions
docstr: ### Initialize
  
  * `params` is the collection of parameters or set of parameter groups.
  * `defaults` a dictionary of default hyper-parameters
  * `lr` is the learning rate, $lpha$
  * `betas` is the tuple $(eta_1, eta_2)$
  * `eps` is $\epsilon$
docstr_tok: ["#","#","#","Initialize","*","`","params","`","is","the","collection","of","parameters","or","set","of","parameter","groups",".","*","`","defaults","`","a","dictionary","of","default","hyper-parameters","*","`","lr","`","is","the","learning","rate",",","$","\u0007lpha","$","*","`","betas","`","is","the","tuple","$","(","\beta_1",",","\beta_2",")","$","*","`","eps","`","is","$","\\epsilon","$"]
code: def __init__(
      self,
      params,
      defaults: Dict[str, Any],
      lr: float,
      betas: Tuple[float, float],
      eps: float,
  ):
      """
      ### Initialize
  
      * `params` is the collection of parameters or set of parameter groups.
      * `defaults` a dictionary of default hyper-parameters
      * `lr` is the learning rate, $\alpha$
      * `betas` is the tuple $(\beta_1, \beta_2)$
      * `eps` is $\epsilon$
      """
  
      # Check the hyper-parameters
      if not 0.0 <= lr:
          raise ValueError(f"Invalid learning rate: {lr}")
      if not 0.0 <= eps:
          raise ValueError(f"Invalid epsilon value: {eps}")
      if not 0.0 <= betas[0] < 1.0:
          raise ValueError(
              f"Invalid beta parameter at index 0: {betas[0]}"
          )
      if not 0.0 <= betas[1] < 1.0:
          raise ValueError(
              f"Invalid beta parameter at index 1: {betas[1]}"
          )
  
      # Add the hyper-parameters to the defaults
      defaults.update(dict(lr=lr, betas=betas, eps=eps))
      # Initialize the PyTorch optimizer.
      # This will create parameter groups with the default hyper-parameters
      super().__init__(params, defaults)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/optimizers/__init__.py
imports: from typing import Dict, Tuple, Any
  import torch
  from torch import nn
  from torch.optim.optimizer import Optimizer
label_desc: Use image node_id 1 to create a new GenericAdaptiveOptimizer object from inherited base classes: Optimizer with example: obj = GenericAdaptiveOptimizer(params, defaults, lr, betas, eps)