class_docstr: KG embedding trainer object.
docstr: Initialize KG trainer.
  
  Args:
    sizes: Tuple of size 3 containing (n_entities, n_rels, n_entities).
    args: Namespace with config arguments (see config.py for detailed overview
      of arguments supported).
docstr_tok: ["Initialize","KG","trainer",".","Args",":","sizes",":","Tuple","of","size","3","containing","(","n_entities",",","n_rels",",","n_entities",")",".","args",":","Namespace","with","config","arguments","(","see","config.py","for","detailed","overview","of","arguments","supported",")","."]
code: def __init__(self, sizes, args):
      """Initialize KG trainer.
  
      Args:
        sizes: Tuple of size 3 containing (n_entities, n_rels, n_entities).
        args: Namespace with config arguments (see config.py for detailed overview
          of arguments supported).
      """
      if args.optimizer == "Adagrad":
          self.optimizer = tf.keras.optimizers.Adagrad(
              learning_rate=args.lr,
              initial_accumulator_value=0.0,
              epsilon=1e-10,
          )
      elif args.optimizer == "Adam":
          self.optimizer = tf.keras.optimizers.Adam(
              learning_rate=args.lr,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=1e-08,
              amsgrad=False,
          )
      else:
          self.optimizer = getattr(tf.keras.optimizers, args.optimizer)(
              learning_rate=args.lr
          )
      self.loss_fn = getattr(losses, args.loss_fn)(
          sizes, args.neg_sample_size
      )
      self.lr_decay = args.lr_decay
      self.min_lr = args.min_lr
  
file_path: neural-structured-learning/research/kg_hyp_emb/learning/trainer.py
imports: from kg_hyp_emb.learning import losses
  import tensorflow
label_desc: Use image node_id 1 to create a new KGTrainer object from inherited base classes: object with example: obj = KGTrainer(sizes, args)