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:
ModuleActivation to mimic inverse transform sampling from some distribution.
- property alpha: Tensor¶
Scale self._alpha to ensure positivity and return.
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:
ModuleBasic 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
Moduleinstance 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:
ModuleBasic 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
Moduleinstance 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.