Menu

Helper Module for Deep Learning.

Variational Auto-Encoder (VAE).

class pynet.models.vae.vae.Decoder(latent_dim, conv_flts, dense_hidden_dims, output_channels, output_dim, noise_out_logvar=-3, noise_fixed=True, act_func=None, final_activation=False, dropout=0)[source]

The decoder part of a VAE.

__init__(latent_dim, conv_flts, dense_hidden_dims, output_channels, output_dim, noise_out_logvar=-3, noise_fixed=True, act_func=None, final_activation=False, dropout=0)[source]

Init class.

Parameters

latent_dim: int

the latent size.

conv_flts: list of int

the size of convolutional filters, if None do not include convolutional layers.

dense_hidden_dims: list of int

the size of dense hidden dimensions, if None do not include dense hidden layers.

output_channels: int

the number of output channels.

output_dim: int or list of int

the size of output.

noise_out_logvar: float, default -3

the init output log var.

noise_fixed: bool, default True

estimate the the output log var.

act_func: callable, default None

the activation function.

final_activation: bool, default False

apply activation function to the final layer.

dropout: float, default 0

define the dropout rate.

forward(z)[source]

The forward method.

static init_conv_layers(input_channels, flts, act_func, dropout, ndim=1, final_activation=True)[source]

Create the convolutional layers.

class pynet.models.vae.vae.Encoder(input_channels, input_dim, conv_flts, dense_hidden_dims, latent_dim, act_func=None, dropout=0, log_alpha=None)[source]

The encoder part of a VAE.

__init__(input_channels, input_dim, conv_flts, dense_hidden_dims, latent_dim, act_func=None, dropout=0, log_alpha=None)[source]

Init class.

Parameters

input_channels: int

the number of input channels.

input_dim: int or list of int

the size of input.

conv_flts: list of int

the size of convolutional filters, if None do not include convolutional layers.

dense_hidden_dims: list of int

the size of dense hidden dimensions, if None do not include dense hidden layers.

latent_dim: int

the latent dimension.

act_func: callable, default None

the activation function.

dropout: float, default 0

define the dropout rate.

log_alpha: nn.Parameter, default None

inducing sparse latent representations.

static compute_logvar(mu, log_alpha)[source]

Compute the log variance in case of sparsity contraints.

static final_conv_dim(input_dim, kernels, paddings)[source]

Infer the size of eaxh sample after the convolutions bloc.

forward(x)[source]

The forward method.

static init_conv_layers(input_channels, flts, act_func, dropout, ndim=1)[source]

Create the convolutional layers.

static init_dense_layers(input_dim, hidden_dims, act_func, dropout, final_activation=True)[source]

Create the dense layers.

class pynet.models.vae.vae.VAENet(input_channels, input_dim, conv_flts, dense_hidden_dims, latent_dim, noise_out_logvar=-3, noise_fixed=True, log_alpha=None, act_func=None, final_activation=False, dropout=0, sparse=False, encoder=None, decoder=None)[source]

The VAE architecture.

Spatiotemporal Trajectories in Resting-state FMRI Revealed by Convolutional Variational Autoencoder, Xiaodi Zhang, Eric Maltbie, Shella Keilholz, bioRxiv 2021.

Deep Variational Autoencoder for Modeleing functional brain networks and ADHD idetification, ISBI 2020.

Sparse Multi-Channel Variational Autoencoder for the Joint Analysis of Heterogeneous Data, Luigi Antelmi, Nicholas Ayache, Philippe Robert, Marco Lorenzi, PMLR 2019.

__init__(input_channels, input_dim, conv_flts, dense_hidden_dims, latent_dim, noise_out_logvar=-3, noise_fixed=True, log_alpha=None, act_func=None, final_activation=False, dropout=0, sparse=False, encoder=None, decoder=None)[source]

Init class.

Parameters

input_channels: int

the number of input channels.

input_dim: int or list of int

the size of input.

conv_flts: list of int

the size of convolutional filters, if None do not include convolutional layers.

dense_hidden_dims: list of int

the size of dense hidden dimensions, if None do not include dense hidden layers.

latent_dim: int

the latent dimension.

noise_out_logvar: float, default -3

the init output log var.

noise_fixed: bool, default True

estimate the the output log var.

log_alpha: nn.Parameter, default None

dropout probabilities estimate.

act_func: callable, default None

the activation function.

final_activation: bool, default False

apply activation function to the final layer.

dropout: float, default 0

define the dropout rate.

sparse: bool, default False

use sparsity contraint.

encoder: nn.Module, default None

a custom encoder.

decoder: nn.Module, default None

a custom decoder.

apply_threshold(z, threshold, keep_dims=True, reorder=False)[source]

Threshold the latent samples based on the estimated dropout probabilities.

property dropout

Compute the dropout probabilities.

forward(x)[source]

The forward method.

generate(z=None, device=None)[source]

Generate a new data from a given sample or a random one.

kernel_initializer()[source]

Init network weights.

static p_to_prediction(p)[source]

Get the prediction from various types of distributions.

reconstruct(x, sample=False)[source]

Reconstruct a new data from a given input with or without resampling.

reparameterize(q)[source]

Implement the reparametrization trick.

set_dropout(deterministic)[source]

Reconfigure the dropout modules.

Follow us

© 2019, pynet developers .
Inspired by AZMIND template.