Initializer

class ampligraph.latent_features.Initializer(initializer_params={}, verbose=True, seed=0)

Abstract class for initializer .

Methods

__init__([initializer_params, verbose, seed]) Initialize the Class
_init_hyperparams(hyperparam_dict) Initializes the hyperparameters.
_get_tf_initializer([in_shape, out_shape, …]) Create a tensorflow node for initializer
_get_np_initializer([in_shape, out_shape, …]) Create an initialized numpy array
_display_params() Display the parameter values
get_entity_initializer([in_shape, …]) Initializer for entity embeddings
get_relation_initializer([in_shape, …]) Initializer for relation embeddings
__init__(initializer_params={}, verbose=True, seed=0)

Initialize the Class

Parameters:
  • initializer_params (dict) – dictionary of hyperparams that would be used by the initializer.
  • verbose (bool) – set/reset verbose mode
  • seed (int/np.random.RandomState) – random state for random number generator
_init_hyperparams(hyperparam_dict)

Initializes the hyperparameters.

Parameters:hyperparam_dict (dictionary) – Consists of key value pairs. The initializer will check the keys to get the corresponding params
_get_tf_initializer(in_shape=None, out_shape=None, concept='e')

Create a tensorflow node for initializer

Parameters:
  • in_shape (int) – number of inputs to the layer (fan in)
  • out_shape (int) – number of outputs of the layer (fan out)
  • concept (char) – concept type (e for entity, r for relation)
Returns:

initializer_instance

Return type:

An Initializer instance.

_get_np_initializer(in_shape=None, out_shape=None, concept='e')

Create an initialized numpy array

Parameters:
  • in_shape (int) – number of inputs to the layer (fan in)
  • out_shape (int) – number of outputs of the layer (fan out)
  • concept (char) – concept type (e for entity, r for relation)
Returns:

initialized_values – Initialized weights

Return type:

n-d array

_display_params()

Display the parameter values

get_entity_initializer(in_shape=None, out_shape=None, init_type='tf')

Initializer for entity embeddings

Parameters:
  • in_shape (int) – number of inputs to the layer (fan in)
  • out_shape (int) – number of outputs of the layer (fan out)
  • init_type (string) – Type of initializer (‘tf’ for tensorflow, ‘np’ for numpy)
Returns:

initialized_values – Weights initializer

Return type:

tf.Op or n-d array

get_relation_initializer(in_shape=None, out_shape=None, init_type='tf')

Initializer for relation embeddings

Parameters:
  • in_shape (int) – number of inputs to the layer (fan in)
  • out_shape (int) – number of outputs of the layer (fan out)
  • init_type (string) – Type of initializer (‘tf’ for tensorflow, ‘np’ for numpy)
Returns:

initialized_values – Weights initializer

Return type:

tf.Op or n-d array