CorruptionGenerationLayerTrain

class ampligraph.latent_features.layers.corruption_generation.CorruptionGenerationLayerTrain(*args, **kwargs)

Generates corruptions during training.

The corruption might involve either subject or object using entities sampled uniformly at random from the loaded graph.

Attributes

Methods

__init__([seed])

Initializes the corruption generation layer.

call(pos, ent_size, eta)

Generates corruption for the positives supplied.

get_config()

Returns the config of the layer.

__init__(seed=0, **kwargs)

Initializes the corruption generation layer.

Parameters:

eta (int) – Number of corruptions to generate.

call(pos, ent_size, eta)

Generates corruption for the positives supplied.

Parameters:
  • pos (array-like, shape (n, 3)) – Batch of input triples (positives).

  • ent_size (int) – Number of unique entities present in the partition.

Returns:

corruptions – Corruptions of the triples.

Return type:

array-like, shape (n * eta, 3)

get_config()

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

Returns:

Python dictionary.