nntoolbox.components.shunting module

Shunting Inhibition Modules

class nntoolbox.components.shunting.GeneralizedShuntingMLP(in_channels: int, out_channels: int, num_activation: torch.nn.modules.module.Module = Identity(), denom_activation: torch.nn.modules.module.Module = ReLU(), bound_denom: bool = True, bound: float = 0.1)[source]

Bases: nntoolbox.components.shunting.GeneralizedShuntingModule

training: bool
class nntoolbox.components.shunting.GeneralizedShuntingModule(num: torch.nn.modules.module.Module, denom: torch.nn.modules.module.Module, bound_denom: bool = True, bound: float = 0.1)[source]

Bases: torch.nn.modules.module.Module

Implement a module that exhibits the shunting inhibition mechanism:

y = f(x) / (a + g(x))

Difference from original implementation: clamping denominator.

References:

Ganesh Arulampalam, Abdesselam Bouzerdoum. “A generalized feedforward neural network architecture for classification and regression.” https://www.sciencedirect.com/science/article/pii/S0893608003001163

forward(input: torch.Tensor) → torch.Tensor[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool