Skip to content

useful_layers

Collection of simple torch.nn.Modules.

Some of them might be useful when building models using Pytorch Symbolic.

pytorch_symbolic.useful_layers

CallbackLayer

CallbackLayer(op: Callable)

Bases: nn.Module

Layer that returns its inputs, but executes a callable op on them before returning.

This can be used for debugging or logging purposes. Accepts only one argument.

Example::

x = CallbackLayer(print)(x)

It does not change anything in x, but prints its value.