class_docstr: Relational Graph Convolution (RGCN) Keras layer.
  
  Original paper: Modeling Relational Data with Graph Convolutional Networks.
  Thomas N. Kipf, Michael Schlichtkrull (2017). https://arxiv.org/pdf/1703.06103.pdf
  
  Notes:
    - The inputs are tensors with a batch dimension of 1:
      Keras requires this batch dimension, and for full-batch methods
      we only have a single "batch".
  
    - There are 1 + R inputs required (where R is the number of relationships): the node features,
      and a normalized adjacency matrix for each relationship
  
  .. seealso:: :class:`.RGCN` combines several of these layers.
  
  Args:
      units (int): dimensionality of output feature vectors
      num_relationships (int): the number of relationships in the graph
      num_bases (int): the number of basis matrices to use for parameterizing the weight matrices as described in
          the paper; defaults to 0. ``num_bases < 0`` triggers the default behaviour of ``num_bases = 0``
      activation (str or func): nonlinear activation applied to layer's output to obtain output features
      use_bias (bool): toggles an optional bias
      final_layer (bool): Deprecated, use ``tf.gather`` or :class:`.GatherIndices`
      kernel_initializer (str or func): The initialiser to use for the self kernel and also relational kernels if ``num_bases=0``.
      kernel_regularizer (str or func): The regulariser to use for the self kernel and also relational kernels if ``num_bases=0``.
      kernel_constraint (str or func): The constraint to use for the self kernel and also relational kernels if ``num_bases=0``.
      basis_initializer (str or func): The initialiser to use for the basis matrices.
      basis_regularizer (str or func): The regulariser to use for the basis matrices.
      basis_constraint (str or func): The constraint to use for the basis matrices.
      coefficient_initializer (str or func): The initialiser to use for the coefficients.
      coefficient_regularizer (str or func): The regulariser to use for the coefficients.
      coefficient_constraint (str or func): The constraint to use for the coefficients.
      bias_initializer (str or func): The initialiser to use for the bias.
      bias_regularizer (str or func): The regulariser to use for the bias.
      bias_constraint (str or func): The constraint to use for the bias.
      input_dim (int, optional): the size of the input shape, if known.
      kwargs: any additional arguments to pass to :class:`tensorflow.keras.layers.Layer`
class_docstr_tok: ["Relational","Graph","Convolution","(","RGCN",")","Keras","layer",".","Original","paper",":","Modeling","Relational","Data","with","Graph","Convolutional","Networks",".","Thomas","N.","Kipf",",","Michael","Schlichtkrull","(","2017",")",".","https",":","\/\/arxiv.org\/pdf\/1703.06103.pdf","Notes",":","-","The","inputs","are","tensors","with","a","batch","dimension","of","1",":","Keras","requires","this","batch","dimension",",","and","for","full-batch","methods","we","only","have","a","single","``","batch","''",".","-","There","are","1","+","R","inputs","required","(","where","R","is","the","number","of","relationships",")",":","the","node","features",",","and","a","normalized","adjacency","matrix","for","each","relationship","..","seealso",":",":",":","class",":","`",".RGCN","`","combines","several","of","these","layers",".","Args",":","units","(","int",")",":","dimensionality","of","output","feature","vectors","num_relationships","(","int",")",":","the","number","of","relationships","in","the","graph","num_bases","(","int",")",":","the","number","of","basis","matrices","to","use","for","parameterizing","the","weight","matrices","as","described","in","the","paper",";","defaults","to","0",".","``","num_bases","<","0","``","triggers","the","default","behaviour","of","``","num_bases","=","0","``","activation","(","str","or","func",")",":","nonlinear","activation","applied","to","layer","'s","output","to","obtain","output","features","use_bias","(","bool",")",":","toggles","an","optional","bias","final_layer","(","bool",")",":","Deprecated",",","use","``","tf.gather","``","or",":","class",":","`",".GatherIndices","`","kernel_initializer","(","str","or","func",")",":","The","initialiser","to","use","for","the","self","kernel","and","also","relational","kernels","if","``","num_bases=0","``",".","kernel_regularizer","(","str","or","func",")",":","The","regulariser","to","use","for","the","self","kernel","and","also","relational","kernels","if","``","num_bases=0","``",".","kernel_constraint","(","str","or","func",")",":","The","constraint","to","use","for","the","self","kernel","and","also","relational","kernels","if","``","num_bases=0","``",".","basis_initializer","(","str","or","func",")",":","The","initialiser","to","use","for","the","basis","matrices",".","basis_regularizer","(","str","or","func",")",":","The","regulariser","to","use","for","the","basis","matrices",".","basis_constraint","(","str","or","func",")",":","The","constraint","to","use","for","the","basis","matrices",".","coefficient_initializer","(","str","or","func",")",":","The","initialiser","to","use","for","the","coefficients",".","coefficient_regularizer","(","str","or","func",")",":","The","regulariser","to","use","for","the","coefficients",".","coefficient_constraint","(","str","or","func",")",":","The","constraint","to","use","for","the","coefficients",".","bias_initializer","(","str","or","func",")",":","The","initialiser","to","use","for","the","bias",".","bias_regularizer","(","str","or","func",")",":","The","regulariser","to","use","for","the","bias",".","bias_constraint","(","str","or","func",")",":","The","constraint","to","use","for","the","bias",".","input_dim","(","int",",","optional",")",":","the","size","of","the","input","shape",",","if","known",".","kwargs",":","any","additional","arguments","to","pass","to",":","class",":","`","tensorflow.keras.layers.Layer","`"]
docstr: Builds the layer
  
  Args:
      input_shapes (list of int): shapes of the layer's inputs
      (node features, node_indices, and adjacency matrices)
docstr_tok: ["Builds","the","layer","Args",":","input_shapes","(","list","of","int",")",":","shapes","of","the","layer","'s","inputs","(","node","features",",","node_indices",",","and","adjacency","matrices",")"]
code: def build(self, input_shapes):
      """
      Builds the layer
  
      Args:
          input_shapes (list of int): shapes of the layer's inputs
          (node features, node_indices, and adjacency matrices)
  
      """
      feat_shape = input_shapes[0]
      input_dim = int(feat_shape[-1])
  
      if self.num_bases > 0:
          # creates a kernel for each edge type/relationship in the graph
          # each kernel is a linear combination of basis matrices
          # the basis matrices are shared for all edge types/relationships
          # each edge type has a different set of learnable coefficients
  
          # initialize the shared basis matrices
          self.bases = self.add_weight(
              shape=(input_dim, self.units, self.num_bases),
              initializer=self.basis_initializer,
              name="bases",
              regularizer=self.basis_regularizer,
              constraint=self.basis_constraint,
          )
  
          # initialize the coefficients for each edge type/relationship
          self.coefficients = [
              self.add_weight(
                  shape=(self.num_bases,),
                  initializer=self.coefficient_initializer,
                  name="coeff",
                  regularizer=self.coefficient_regularizer,
                  constraint=self.coefficient_constraint,
              )
              for _ in range(self.num_relationships)
          ]
  
          # To support eager TF the relational_kernels need to be explicitly calculated
          # each time the layer is called
          self.relational_kernels = None
  
      else:
          self.bases = None
          self.coefficients = None
  
          self.relational_kernels = [
              self.add_weight(
                  shape=(input_dim, self.units),
                  name="relational_kernels",
                  initializer=self.kernel_initializer,
                  regularizer=self.kernel_regularizer,
                  constraint=self.kernel_constraint,
              )
              for _ in range(self.num_relationships)
          ]
  
      self.self_kernel = self.add_weight(
          shape=(input_dim, self.units),
          name="self_kernel",
          initializer=self.kernel_initializer,
          regularizer=self.kernel_regularizer,
          constraint=self.kernel_constraint,
      )
  
      if self.use_bias:
          self.bias = self.add_weight(
              shape=(self.units,),
              initializer=self.bias_initializer,
              name="bias",
              regularizer=self.bias_regularizer,
              constraint=self.bias_constraint,
          )
      else:
          self.bias = None
  
      self.built = True
  
file_path: stellargraph/stellargraph/layer/rgcn.py
imports: import tensorflow
  from tensorflow.keras import backend
  from tensorflow.keras.layers import Layer, Lambda, Dropout, Input
  from tensorflow.keras import activations, initializers, constraints, regularizers
  from .misc import SqueezedSparseConversion, deprecated_model_function, GatherIndices
  from ..mapper.full_batch_generators import RelationalFullBatchNodeGenerator
label_desc: Use image node_id 4 for calling the RelationalGraphConvolution obj's underlying member method code with example usage: obj.build(input_shapes) without return types