deeprob.flows.layers package
Submodules
deeprob.flows.layers.autoregressive module
- class deeprob.flows.layers.autoregressive.AutoregressiveLayer(in_features, depth, units, activation, reverse=False, sequential=True, random_state=None)[source]
Bases:
BijectorBuild an autoregressive layer as specified in Masked Autoregressive Flow paper.
- Parameters
in_features (int) – The number of input features.
depth (int) – The number of hidden layers of the conditioner.
units (int) – The number of units of each hidden layer of the conditioner.
activation (str) – The activation used for inner layers of the conditioner.
reverse (bool) – Whether to reverse the mask used in the autoregressive layer. Used only if sequential is True.
sequential (bool) – Whether to use sequential degrees for inner layers masks.
random_state (Optional[RandomState]) – The random state used to generate the masks degrees. Used only if sequential is False.
- Raises
ValueError – If a parameter is out of domain.
- build_degrees_sequential(depth, units, reverse)[source]
Build sequential degrees for the linear layers of the autoregressive network.
- Parameters
- Returns
The masks to use for each hidden layer of the autoregressive network.
- Return type
- build_degrees_random(depth, units, random_state)[source]
Create random degrees for the linear layers of the autoregressive network.
- Parameters
depth (int) – The number of hidden layers of the conditioner.
units (int) – The number of units of each hidden layer of the conditioner.
random_state (RandomState) – The random state.
- Returns
The masks to use for each hidden layer of the autoregressive network.
- Return type
deeprob.flows.layers.coupling module
- class deeprob.flows.layers.coupling.CouplingLayer1d(in_features, depth, units, affine=True, reverse=False)[source]
Bases:
BijectorBuild a RealNVP (or NICE) 1D coupling layer.
- Parameters
in_features (int) – The number of input features.
depth (int) – The number of hidden layers of the conditioner.
units (int) – The number of units of each hidden layer of the conditioner.
affine (bool) – Whether to use affine transformation. If False then use only translation (as in NICE).
reverse (bool) – Whether to reverse the mask used in the coupling layer. Useful for alternating masks.
- class deeprob.flows.layers.coupling.CouplingLayer2d(in_features, network, n_blocks, channels, affine=True, channelwise=False, reverse=False)[source]
Bases:
BijectorBuild a RealNVP (or NICE) 2D coupling layer.
- Parameters
network (str) – The network conditioner to use. It can be either ‘resnet’ or ‘densenet’.
n_blocks (int) – The number of residual blocks or dense blocks.
channels (int) – The number of output channels of each convolutional layer.
affine (bool) – Whether to use affine transformation. If False then use only translation (as in NICE).
channelwise (bool) – Whether to use channel-wise coupling mask. Defaults to False, i.e. checkerboard coupling mask.
reverse (bool) – Whether to reverse the mask used in the coupling layer. Useful for alternating masks.
- class deeprob.flows.layers.coupling.CouplingBlock2d(in_features, network, n_blocks, channels, affine=True, last_block=False)[source]
Bases:
BijectorBuild a RealNVP (or NICE) 2D coupling block, consisting of check-board/channel-wise couplings and squeeze operation.
- Parameters
network (str) – The network conditioner to use. It can be either ‘resnet’ or ‘densenet’.
n_blocks (int) – The number of residual blocks or dense blocks.
channels (int) – The number of output channels of each convolutional layer.
affine (bool) – Whether to use affine transformation. If False then use only translation (as in NICE).
last_block (bool) – Whether it is the last block (i.e. no channelwise-masked couplings) or not.
deeprob.flows.layers.densenet module
- class deeprob.flows.layers.densenet.DenseLayer(in_channels, out_channels, use_checkpoint=False)[source]
Bases:
ModuleInitialize a dense layer as in DenseNet.
- Parameters
- class deeprob.flows.layers.densenet.DenseBlock(n_layers, in_channels, out_channels, use_checkpoint=False)[source]
Bases:
ModuleInitialize a dense block as in DenseNet.
- Parameters
- class deeprob.flows.layers.densenet.Transition(in_channels, out_channels, bias=True)[source]
Bases:
ModuleInitialize a transition layer as in DenseNet.
- Parameters
- class deeprob.flows.layers.densenet.DenseNetwork(in_channels, mid_channels, out_channels, n_blocks, use_checkpoint=False)[source]
Bases:
ModuleInitialize a dense network (DenseNet) with only one dense block.
- Parameters
in_channels (int) – The number of input channels.
mid_channels (int) – The number of mid channels.
out_channels (int) – The number of output channels.
n_blocks (int) – The number of dense blocks.
use_checkpoint (bool) – Whether to use a checkpoint in order to reduce memory usage (by increasing training time caused by re-computations).
deeprob.flows.layers.resnet module
- class deeprob.flows.layers.resnet.ResidualBlock(n_channels)[source]
Bases:
ModuleBuild a basic residual block as in ResNet.
- Parameters
n_channels (int) – The number of channels.
- class deeprob.flows.layers.resnet.ResidualNetwork(in_channels, mid_channels, out_channels, n_blocks)[source]
Bases:
ModuleInitialize a residual network (ResNet) with skip connections.
- Parameters
- Raises
ValueError – If a parameter is out of domain.