class_docstr: Abstract Knowledge Graph embedding model class.
  
  Module to define basic operations in KG embedding models, including embedding
  initialization, computing embeddings and triples' scores.
class_docstr_tok: ["Abstract","Knowledge","Graph","embedding","model","class",".","Module","to","define","basic","operations","in","KG","embedding","models",",","including","embedding","initialization",",","computing","embeddings","and","triples","'","scores","."]
docstr: Initialize KG embedding model.
  
  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","embedding","model",".","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 embedding model.
  
      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).
      """
      super(KGModel, self).__init__()
      self.sizes = sizes
      self.rank = args.rank
      self.bias = args.bias
      self.initializer = getattr(
          tf.keras.initializers, args.initializer
      )
      self.entity_regularizer = getattr(regularizers, args.regularizer)(
          args.entity_reg
      )
      self.rel_regularizer = getattr(regularizers, args.regularizer)(
          args.rel_reg
      )
      self.entity = tf.keras.layers.Embedding(
          input_dim=sizes[0],
          output_dim=self.rank,
          embeddings_initializer=self.initializer,
          embeddings_regularizer=self.entity_regularizer,
          name="entity_embeddings",
      )
      self.rel = tf.keras.layers.Embedding(
          input_dim=sizes[1],
          output_dim=self.rank,
          embeddings_initializer=self.initializer,
          embeddings_regularizer=self.rel_regularizer,
          name="relation_embeddings",
      )
      train_biases = self.bias == "learn"
      self.bh = tf.keras.layers.Embedding(
          input_dim=sizes[0],
          output_dim=1,
          embeddings_initializer="zeros",
          name="head_biases",
          trainable=train_biases,
      )
      self.bt = tf.keras.layers.Embedding(
          input_dim=sizes[0],
          output_dim=1,
          embeddings_initializer="zeros",
          name="tail_biases",
          trainable=train_biases,
      )
      self.gamma = tf.Variable(
          initial_value=args.gamma * tf.keras.backend.ones(1),
          trainable=False,
      )
  
file_path: neural-structured-learning/research/kg_hyp_emb/models/base.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  from kg_hyp_emb.learning import regularizers
  import numpy
  import tensorflow
label_desc: Use image node_id 1 to create a new KGModel object from inherited base classes: tf.keras, abc with example: obj = KGModel(sizes, args)