ab.hlayers

Higher-order neural network layers (made from other layers).

class aboleth.hlayers.Concat(*layers)

Bases: aboleth.baselayers.MultiLayer

Concatenates the output of multiple layers.

Parameters:layers ([MultiLayer]) – The layers to concatenate.
__call__(**kwargs)

Construct the subgraph for this layer.

Parameters:**kwargs – the inputs to this layer (Tensors)
Returns:
  • Net (Tensor) – the output of this layer
  • KL (float, Tensor) – the regularizer/Kullback Leibler ‘cost’ of the parameters in this layer.
class aboleth.hlayers.PerFeature(*layers, slices=None)

Bases: aboleth.baselayers.Layer

Concatenate multiple layers with sliced inputs.

Each layer will recieve a slice along the last axis of the input to the new function. In other words, PerFeature(l1, l2)(X) will call l1(X[..., 0]) and l2(X[..., 1]) then concatenate their outputs into a single tensor. This is mostly useful for simplifying embedding multiple categorical inputs that are stored columnwise in the same 2D tensor.

This function assumes the tensor being provided is 3D.

Parameters:
  • layers ([Layer]) – The layers to concatenate.
  • slices ([slice]) – The slices into X to give to each layer, this has to be the same length as layers. If this is None, it will give columns of X to each layer, the number of columns is determined by the number of layers.
__call__(X)

Construct the subgraph for this layer.

Parameters:X (Tensor) – the input to this layer
Returns:
  • Net (Tensor) – the output of this layer
  • KL (float, Tensor) – the regularizer/Kullback Leibler ‘cost’ of the parameters in this layer.
class aboleth.hlayers.Sum(*layers)

Bases: aboleth.baselayers.MultiLayer

Sums multiple layers by adding their outputs.

Parameters:layers ([MultiLayer]) – The layers to add.
__call__(**kwargs)

Construct the subgraph for this layer.

Parameters:**kwargs – the inputs to this layer (Tensors)
Returns:
  • Net (Tensor) – the output of this layer
  • KL (float, Tensor) – the regularizer/Kullback Leibler ‘cost’ of the parameters in this layer.