fastbnns.models package

Submodules

fastbnns.models.activations module

Custom activation functions.

class fastbnns.models.activations.InverseTransformSampling(distribution: Distribution = Normal(loc: 0.0, scale: 1.0), learn_alpha: bool = False, alpha_init: tensor = tensor([1.]), eps: float = 1e-06, *args, **kwargs)[source]

Bases: Module

Activation to mimic inverse transform sampling from some distribution.

property alpha: Tensor

Scale self._alpha to ensure positivity and return.

forward(x: Tensor) Tensor[source]

Forward pass through activation.

fastbnns.models.activations.scaled_sigmoid(x: Tensor, alpha: Tensor = tensor(1.)) Tensor[source]

Compute the scaled sigmoid function rac{1.0}{1.0+exp(-lpha*x)}

fastbnns.models.cnn module

Simple CNN PyTorch models.

class fastbnns.models.cnn.CNN(in_channels: int, out_channels: int, hidden_features: int = 8, n_hidden_layers: int = 3, kernel_size: int = 3, stride: int = 1, padding: int | str = 'same', activation: type = <class 'torch.nn.modules.activation.LeakyReLU'>)[source]

Bases: Module

Basic multi-layer CNN.

forward(x: Tensor) Tensor[source]

Define 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.

fastbnns.models.lightning_wrappers module

fastbnns.models.mlp module

Simple MLP PyTorch models.

class fastbnns.models.mlp.MLP(in_features: int, out_features: int, hidden_features: int = 128, n_hidden_layers: int = 3, activation: type = <class 'torch.nn.modules.activation.LeakyReLU'>)[source]

Bases: Module

Basic multi-layer perceptron.

forward(x: Tensor) Tensor[source]

Define 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.

fastbnns.models.polynomial module

Torch module for basic polynomials.

class fastbnns.models.polynomial.PolyModule(poly_order: int = 1)[source]

Bases: Module

Polynomial model.

forward(input: Tensor | MuVar) Tensor[source]

Forward pass through module.

Module contents