src.model.deeplearn.layer.layer

Classes

Layer(*args, **kwargs)

class src.model.deeplearn.layer.layer.Layer(*args, **kwargs)
Author:

Alberto M. Esmoris Pena

A layer can be seen as a map \(f\) from an arbitrary tuple of input tensors \(\mathcal{X}_{1}, \ldots, \mathcal{X}_{m}\) to an arbitrary tuple of output tensors \(\mathcal{Y}_{1}, \ldots, \mathcal{Y}_{n}\), i.e., \(f(\mathcal{X}_1, \ldots, \mathcal{X}_m) = (\mathcal{Y}_1, \ldots, \mathcal{Y}_n)\).

The Layer class provides an interface that must be realized by any class that must assume the role of a layer inside a neural network.

__init__(**kwargs)

Initialize the member attributes of the layer and the internal weights that do not depend on the input dimensionality.

Parameters:

kwargs – The key-word specification to parametrize the layer.

build(dim_in)

Logic to build the layer before the first call is executed.

This method can be overloaded by any derived class to either change or extend the logic.

Parameters:

dim_in – The dimensionality of the input tensor.

call(inputs, training=False, mask=False)

The layer’s computation logic.

Parameters:
  • inputs – The input tensor or the list of input tensors.

  • training (bool) – True when the layer is called during training, False otherwise.

  • mask – Boolean mask (one boolean per input timestep).

Returns:

The output tensor.

get_config()

Obtain the dictionary specifying how to serialize the layer.

Returns:

The dictionary with the necessary data to serialize the layer.

Return type:

dict

classmethod from_config(config)

Deserialize a layer from given specification.

Parameters:

config – The dictionary specifying how to deserialize the layer.

Returns:

The deserialized layer.

Return type:

Layer or derived