Belle II Software  release-06-01-15
Relations Class Reference
Inheritance diagram for Relations:
Collaboration diagram for Relations:

Public Member Functions

def __init__ (self, number_features, hidden_feature_shape=[30, 30, 30, 30], activation=tanh, **kwargs)
 
def build (self, input_shape)
 
def call (self, inputs)
 
def compute_output_shape (self, input_shape)
 
def get_config (self)
 

Public Attributes

 number_features
 Number of features. More...
 
 number_groups
 Number of groups in input.
 
 hidden_feature_shape
 shape of hidden layers used for extracting relations
 
 activation
 activation used for hidden layer in shared weights. More...
 
 group_len
 how many neurons has one comparable object
 
 weightvariables
 saves weights for call
 
 combinations
 number of relation combinations
 

Detailed Description

This is a class which implements Relational Layer into Keras.
Relational Layer compares every combination of two feature groups with shared weights.
Use this class as every other Layer in Keras.
Relevant Paper: https://arxiv.org/abs/1706.01427
RN(O) = f_phi(sum_phi(g_theta(o_i,o_j)))
For flexibility reason only the part g(o_i,o_j) is modelled
f_phi corresponds to a MLP net
To sum over all permutations please use GlobalAveragePooling1D from keras.

Definition at line 20 of file keras_relational.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  number_features,
  hidden_feature_shape = [30, 30, 30, 30],
  activation = tanh,
**  kwargs 
)
Init class.

Definition at line 32 of file keras_relational.py.

32  def __init__(self, number_features, hidden_feature_shape=[30, 30, 30, 30], activation=tanh, **kwargs):
33  """
34  Init class.
35  """
36 
37 
38  self.number_features = number_features
39 
40  self.number_groups = 0
41 
42  self.hidden_feature_shape = hidden_feature_shape
43 
44  self.activation = activations.get(activation)
45 
46  self.group_len = 0
47 
48  self.weightvariables = []
49 
50  self.combinations = 0
51 
52  super(Relations, self).__init__(**kwargs)
53 

Member Function Documentation

◆ build()

def build (   self,
  input_shape 
)
Build all weights for Relations Layer
:param input_shape: Input shape of tensor
:return:  Nothing

Definition at line 54 of file keras_relational.py.

◆ call()

def call (   self,
  inputs 
)
Compute Relational Layer
:param inputs: input tensor
:return: output tensor

Definition at line 81 of file keras_relational.py.

◆ compute_output_shape()

def compute_output_shape (   self,
  input_shape 
)
Compute Output shape
:return: Output shape

Definition at line 102 of file keras_relational.py.

◆ get_config()

def get_config (   self)
Config required for saving parameters in keras model.

Definition at line 114 of file keras_relational.py.

Member Data Documentation

◆ activation

activation

activation used for hidden layer in shared weights.

For output sigmoid will always be used.

Definition at line 44 of file keras_relational.py.

◆ number_features

number_features

Number of features.

Number of different shared weights used for comparison for each relation.

Definition at line 38 of file keras_relational.py.


The documentation for this class was generated from the following file: