Pytorch models

class ConvBlock(layout, in_channels=None, filters=None, kernel_size=3, stride=1, padding='same', rate=0.1, activation=None)[source]

Convolutional block.

Parameters
  • in_channels (int) – Input channels size.

  • layout (str) – Layout of layers. Can contain “c” for convolution, “a” for activation, “n” for batchnorm, “p” for maxpooling, “d” for dropout. E.g. of layout: “ccnapd”.

  • filters (int, list or None) – Number of filters for convolutions. Can be a single number (all convolutions will have the same number of filters), a list of the same length as a count of letters “c” in the layout, or None if the layout contains no “c”.

  • rate (float) – Dropout rate parameter. Default to 0.1.

  • activation (function) – Activation function. If not specified activation is tf.nn.elu.

forward(x)[source]

Forward pass.

training = None
class Unet(in_channels, depth, init_filters, kernel_size=3, output=None, norm=True)[source]

U-net implementation.

Parameters
  • in_channels (int) – Input channels size.

  • depth (int) – Depth of the U-net.

  • init_filters (int) – Number of filters in the first conv block.

  • output (dict) – Output conv block config.

forward(x)[source]

Forward pass.

training = None
class VAE(in_channels, filters_enc, filters_dec, z_dim, output, kernel_size=3, norm=True, variational=True)[source]

Convolutional VAE model.

Parameters
  • in_channels (int) – Input channels size.

  • filters_enc (array) – Sequence of filters for encoder.

  • filters_enc – Sequence of filters for decoder.

  • z_dim (int) – Number of filters in the latent space.

  • output (dict) – Output conv block config for decoder.

  • kernel_size (int) – Kernel size in convolution layers. Default 3.

  • norm (bool) – Include normalization layers. Default True.

  • variational (bool) – If False, implemnt ordinary AE scheme. Default True.

decode(z)[source]

Decoder.

encode(x)[source]

Encoder.

forward(x)[source]

Forward pass.

reparameterize(mu, logvar)[source]

Reparametrization trick.

training = None