:py:mod:`nessai.flows.utils` ============================ .. py:module:: nessai.flows.utils .. autoapi-nested-parse:: Various utilities for implementing normalising flows. .. !! processed by numpydoc !! Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: nessai.flows.utils.MLP Functions ~~~~~~~~~ .. autoapisummary:: nessai.flows.utils.silu nessai.flows.utils.configure_model nessai.flows.utils.reset_weights nessai.flows.utils.reset_permutations nessai.flows.utils.create_linear_transform Attributes ~~~~~~~~~~ .. autoapisummary:: nessai.flows.utils.logger .. py:data:: logger .. !! processed by numpydoc !! .. py:function:: silu(x) SiLU (Sigmoid-weighted Linear Unit) activation function. Also known as swish. Elfwing et al 2017: https://arxiv.org/abs/1702.03118v3 .. !! processed by numpydoc !! .. py:function:: configure_model(config) Setup the flow form a configuration dictionary. .. !! processed by numpydoc !! .. py:function:: reset_weights(module) Reset parameters of a given module in place. Uses the ``reset_parameters`` method from ``torch.nn.Module`` Also checks the following modules from nflows - nflows.transforms.normalization.BatchNorm :Parameters: **module** : :obj:`torch.nn.Module` Module to reset .. !! processed by numpydoc !! .. py:function:: reset_permutations(module) Resets permutations and linear transforms for a given module in place. Resets using the original initialisation method. This needed since they do not have a ``reset_parameters`` method. :Parameters: **module** : :obj:`torch.nn.Module` Module to reset .. !! processed by numpydoc !! .. py:class:: MLP(in_shape, out_shape, hidden_sizes, activation=F.relu, activate_output=False) Bases: :py:obj:`nflows.nn.nets.MLP` MLP which can be called with context. .. !! processed by numpydoc !! .. py:method:: forward(self, inputs, context=None) Forward method that allows for kwargs such as context. :Parameters: **inputs** : :obj:`torch.tensor` Inputs to the MLP **context** : None Conditional inputs, must be None. Only implemented to the function is compatible with other methods. :Raises: RuntimeError If the context is not None. .. !! processed by numpydoc !! .. py:function:: create_linear_transform(linear_transform, features) Function for creating linear transforms. :Parameters: **linear_transform** : {'permutation', 'lu', 'svd'} Linear transform to use. **featres** : int Number of features. .. !! processed by numpydoc !!