Linear Layers#
Classes#
- class Activation(*, activation='ELU', shapes=None, activation_kwargs=None, **kwargs)[source]#
Bases:
BaseSingleLayerActivation layer constructor.
- Attributes:
- group
int Layer group, if 0 it will always be used, else it will only be used if its group matches the Networks
- description
str Description of the layer
- layers
Sequential Layers to loop through in the forward pass
- group
- Parameters:
- activation
str,Optional Which activation function to use from PyTorch, default = ‘ELU’
- shapes
Shapes|NoneType,Optional Shape of the outputs from each layer, only required if tracking layer outputs is necessary
- activation_kwargs
dict[str,Any] |NoneType,Optional Additional keyword arguments to pass to the activation function
- **kwargs
Leftover parameters to pass to base layer for checking
- activation
- class Linear(net_out, shapes, *, features=None, layer=None, factor=None, batch_norm=False, flatten_target=False, dropout=0, activation='SELU', **kwargs)[source]#
Bases:
BaseSingleLayerLinear layer constructor.
- Attributes:
- group
int Layer group, if 0 it will always be used, else it will only be used if its group matches the Networks
- description
str Description of the layer
- layers
Sequential Layers to loop through in the forward pass
- group
- Parameters:
- net_out
list[int] Shape of the network’s output
- shapes
Shapes Shape of the outputs from each layer
- features
int|NoneType,Optional Number of output features for the layer, if factor is provided, features will not be used
- layer
int|NoneType,Optional If factor is not None, which layer for factor to be relative to, if None, network output will be used
- factor
float|NoneType,Optional Output features is equal to the factor of the network’s output, or if layer is provided, which layer to be relative to, will be used if provided, else features will be used
- batch_normbool,
Optional If batch normalisation should be used, default = False
- flatten_targetbool,
Optional If the target should be flattened so that features is equal to the product of the target multiplied by factor, if factor is provided, default = False
- dropout
float,Optional Probability of dropout, default = 0
- activation
str|NoneType,Optional Which activation function to use from PyTorch, default = ‘SELU’
- **kwargs
Leftover parameters to pass to base layer for checking
- net_out
- class OrderedBottleneck(shapes, *, min_size=0, **kwargs)[source]#
Bases:
BaseLayerInformation-ordered bottleneck to randomly change the size of the bottleneck in an autoencoder to encode the most important information in the first values of the latent space.
See Information-Ordered Bottlenecks for Adaptive Semantic Compression by Ho et al. (2023).
- Attributes:
- Parameters:
- extra_repr()[source]#
Displays layer parameters when printing the network
- Returns:
strLayer parameters
- class Sample(idx, shapes, **kwargs)[source]#
Bases:
BaseLayerSamples random values from a Gaussian distribution for a variational autoencoder, mean and standard deviation are the first and second half of the input channels with the last channel ignored if there are an odd number.
- Attributes:
- Parameters:
- forward(x, net, *_, **__)[source]#
Forward pass of the sampling layer for a variational autoencoder
- Parameters:
- Returns:
TensorOutput tensor sampled from the input tensor split into mean and standard deviation with shape (N,C/2,…) | (N,Z/2) and type float
- to(*args, **kwargs)[source]#
See
torch.nn.Module.to().
- class Upsample(idx, shapes, *, shape=None, scale=2, mode='nearest', **kwargs)[source]#
Bases:
BaseSingleLayerConstructs an upsampler.
- Attributes:
- group
int Layer group, if 0 it will always be used, else it will only be used if its group matches the Networks
- description
str Description of the layer
- layers
Sequential Layers to loop through in the forward pass
- group
- Parameters:
- idx
int Layer number
- shapes
Shapes Shape of the outputs from each layer
- shape
list[int] |NoneType,Optional Shape of the output, will be used if provided, else scale will be used
- scale
float|tuple[float] |tuple[float, …],Optional Factor to upscale all or individual dimensions, first dimension is ignored, won’t be used if shape is provided, default = 2
- mode{‘nearest’, ‘linear’, ‘bilinear’, ‘bicubic’, ‘trilinear’}
What interpolation method to use for upsampling
- **kwargs
Leftover parameters to pass to base layer for checking
- idx