Menu

Helper Module for Deep Learning.

This module provides a registery with ready to use networks that are grouped into diferent categories: segmentation, registration, encoder, and classifier.

class pynet.interfaces.ADDNetRegister(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

ADDNet.

Affine and Dense Deformable Network (ADDNet): affine registration subnetwork predicts a set of affine parameters, after which a flow field can be generated for warping.

Reference: https://arxiv.org/pdf/1902.05020. Code: https://github.com/microsoft/Recursive-Cascaded-Networks.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: uplet

the tensor data shape (X, Y, Z).

in_channels: int

number of channels in the input tensor.

kernel_size: int, default 3

the convolution kernels size (odd number).

padding: int, default 1

the padding size, recommended (kernel_size - 1) / 2

flow_multiplier: foat, default 1

weight the flow field by this factor.

class pynet.interfaces.BrainNetCNNGraph(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

BrainNetCNN.

BrainNetCNN is composed of novel edge-to-edge, edge-to-node and node-to-graph convolutional filters (layers) that leverage the topological locality of structural brain networks.

An E2E filter computes a weighted sum of edge weights over all edges connected either to node i or j, like a convolution. An E2N filter summarizes the responses of neighbouring edges into a set of node responses. A N2G filter can be interpreted as getting a single response from all the nodes in the graph.

BrainNetCNN is able to predict an infant’s age with an average error of about 2 weeks, demonstrating that it can learn relevant topological features from the connectome data. BrainNetCNN can also be applied to the much more challenging task of predicting neurodevelopmental scores.

Reference: https://www2.cs.sfu.ca/~hamarneh/ecopy/neuroimage2017.pdf. Code: https://github.com/nicofarr/brainnetcnnVis_pytorch.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: tuple

the size of the functional connectivity matrix.

in_channels: int

number of channels in the input tensor.

num_classes: int

the number of classes to be predicted.

twice_e2e: bool, default False

if set use two E2E filter twice.

nb_e2e: int, default 32

number of e2e filters.

nb_e2n: int, default 64

number of e2n filters.

nb_n2g: int, default 30

number of n2g filters.

dropout: float, default 0.5

the dropout rate.

leaky_alpha: float, default 0.33

leaky ReLU alpha rate.

twice_e2e: bool, default False

if set apply two times the Edge-to-Edge layer.

dense_sml: bool, default True

if set reduce the number of hidden dense layers otherwise set nb_n2g to 256.

class pynet.interfaces.DeepClusterClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Deep Clustering for Unsupervised Learning of Visual Features.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

network: @callable

the network used to compute the features.

clustering: @callable

the clustering algorithm.

data_loader: DataLoader

the train data loader.

n_batchs: int

the number of batchs used to computes network features.

pca_dim: int, default 256

the dimension of input clustering features.

assignment_logfile: str, default None

save the cluster assignements at each epoch.

use_cuda: bool, default False

wether to use GPU or CPU.

class pynet.interfaces.DeepLabNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Deep Labeling for Semantic Image Segmentation.

Implementation of the DeepLabV3+ variant.

DeepLabv3 employs atrous convolution to extract the features computed by deep convolutional neural networks at anarbitrary resolution. Here, we denote output stride as the ratio of input image spatial resolution to the final output resolution (before global pooling or fully-connected layer).

Reference: https://arxiv.org/pdf/1802.02611.pdf Code: https://github.com/cv-lee/BraTs

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int, default 2

the number of features in the output segmentation map.

class pynet.interfaces.DeepLabNetSegmenter(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Deep Labeling for Semantic Image Segmentation.

Implementation of the DeepLabV3+ variant.

DeepLabv3 employs atrous convolution to extract the features computed by deep convolutional neural networks at anarbitrary resolution. Here, we denote output stride as the ratio of input image spatial resolution to the final output resolution (before global pooling or fully-connected layer).

Reference: https://arxiv.org/pdf/1802.02611.pdf Code: https://github.com/cv-lee/BraTs

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int, default 2

the number of features in the output segmentation map.

class pynet.interfaces.DeepLearningDecorator(family)[source]

Decorator to determine the networks that need to be warped in the Deep Leanring interface environment.

In order to make the class publicly accessible, we assign the result of the function to a variable dynamically using globals().

__init__(family)[source]

Initialize the ValidationDecorator class.

Parameters

family: str or list of str

the families associated to the network.

class pynet.interfaces.DeepLearningInterface(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)[source]

Class to define ready to use Deep Learning interface for defined networks. An attributes section will be used for the documentation of the network parameters.

__init__(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)[source]

Class initilization.

Parameters

net_params: NetParameters, default None

all the parameters that will be used during the network creation.

pretrained: path, default None

path to the pretrained model or weights.

resume: bool, default False

if set to true, the code will restore the weights of the model but also restore the optimizer’s state, as well as the hyperparameters used, and the scheduler.

add_labels: bool, default False

if set and labels are specified in the data manager, add the labels to the forward function parameters.

optimizer_name: str, default ‘Adam’

the name of the optimizer: see ‘torch.optim’ for a description of available optimizer.

learning_rate: float, default 1e-3

the optimizer learning rate.

loss_name: str, default ‘NLLLoss’

the name of the loss: see ‘torch.nn’ for a description of available loss.

metrics: list of str

a list of extra metrics that will be computed.

use_cuda: bool, default False

wether to use GPU or CPU.

kwargs: dict

specify directly a custom ‘optimizer’ or ‘loss’. Can also be used to set specific optimizer parameters.

class pynet.interfaces.DeepLearningMetaRegister[source]

Simple Python metaclass registry pattern.

REGISTRY = {'ADDNetRegister': <class 'pynet.interfaces.ADDNetRegister'>, 'BrainNetCNNGraph': <class 'pynet.interfaces.BrainNetCNNGraph'>, 'DeepClusterClassifier': <class 'pynet.interfaces.DeepClusterClassifier'>, 'DeepLabNetEncoder': <class 'pynet.interfaces.DeepLabNetEncoder'>, 'DeepLabNetSegmenter': <class 'pynet.interfaces.DeepLabNetSegmenter'>, 'DenseNet121Classifier': <class 'pynet.interfaces.DenseNet121Classifier'>, 'DenseNet161Classifier': <class 'pynet.interfaces.DenseNet161Classifier'>, 'DenseNet169Classifier': <class 'pynet.interfaces.DenseNet169Classifier'>, 'DenseNet201Classifier': <class 'pynet.interfaces.DenseNet201Classifier'>, 'DenseNetClassifier': <class 'pynet.interfaces.DenseNetClassifier'>, 'GMVAENetClassifier': <class 'pynet.interfaces.GMVAENetClassifier'>, 'GMVAENetEncoder': <class 'pynet.interfaces.GMVAENetEncoder'>, 'GMVAENetVae': <class 'pynet.interfaces.GMVAENetVae'>, 'Inception3Classifier': <class 'pynet.interfaces.Inception3Classifier'>, 'MCVAEEncoder': <class 'pynet.interfaces.MCVAEEncoder'>, 'MCVAEVae': <class 'pynet.interfaces.MCVAEVae'>, 'MOESimVAENetEncoder': <class 'pynet.interfaces.MOESimVAENetEncoder'>, 'MOESimVAENetVae': <class 'pynet.interfaces.MOESimVAENetVae'>, 'NvNetSegmenter': <class 'pynet.interfaces.NvNetSegmenter'>, 'PMVAEEncoder': <class 'pynet.interfaces.PMVAEEncoder'>, 'PMVAEGenetic': <class 'pynet.interfaces.PMVAEGenetic'>, 'PMVAEVae': <class 'pynet.interfaces.PMVAEVae'>, 'PSPNetEncoder': <class 'pynet.interfaces.PSPNetEncoder'>, 'PSPNetSegmenter': <class 'pynet.interfaces.PSPNetSegmenter'>, 'RCNetRegister': <class 'pynet.interfaces.RCNetRegister'>, 'ResAENetEncoder': <class 'pynet.interfaces.ResAENetEncoder'>, 'ResNet101Classifier': <class 'pynet.interfaces.ResNet101Classifier'>, 'ResNet101WideClassifier': <class 'pynet.interfaces.ResNet101WideClassifier'>, 'ResNet101x32x8dClassifier': <class 'pynet.interfaces.ResNet101x32x8dClassifier'>, 'ResNet152Classifier': <class 'pynet.interfaces.ResNet152Classifier'>, 'ResNet18Classifier': <class 'pynet.interfaces.ResNet18Classifier'>, 'ResNet34Classifier': <class 'pynet.interfaces.ResNet34Classifier'>, 'ResNet50Classifier': <class 'pynet.interfaces.ResNet50Classifier'>, 'ResNet50WideClassifier': <class 'pynet.interfaces.ResNet50WideClassifier'>, 'ResNet50x32x4dClassifier': <class 'pynet.interfaces.ResNet50x32x4dClassifier'>, 'ResNetClassifier': <class 'pynet.interfaces.ResNetClassifier'>, 'STAAENetEncoder': <class 'pynet.interfaces.STAAENetEncoder'>, 'SonoNetClassifier': <class 'pynet.interfaces.SonoNetClassifier'>, 'SphericalUNetEncoder': <class 'pynet.interfaces.SphericalUNetEncoder'>, 'UNetEncoder': <class 'pynet.interfaces.UNetEncoder'>, 'UNetSegmenter': <class 'pynet.interfaces.UNetSegmenter'>, 'VAEGMPNetEncoder': <class 'pynet.interfaces.VAEGMPNetEncoder'>, 'VAEGMPNetVae': <class 'pynet.interfaces.VAEGMPNetVae'>, 'VAENetEncoder': <class 'pynet.interfaces.VAENetEncoder'>, 'VAENetVae': <class 'pynet.interfaces.VAENetVae'>, 'VGG11Classifier': <class 'pynet.interfaces.VGG11Classifier'>, 'VGG13Classifier': <class 'pynet.interfaces.VGG13Classifier'>, 'VGG16Classifier': <class 'pynet.interfaces.VGG16Classifier'>, 'VGG19Classifier': <class 'pynet.interfaces.VGG19Classifier'>, 'VGGClassifier': <class 'pynet.interfaces.VGGClassifier'>, 'VTNetRegister': <class 'pynet.interfaces.VTNetRegister'>, 'VaDENetClassifier': <class 'pynet.interfaces.VaDENetClassifier'>, 'VaDENetEncoder': <class 'pynet.interfaces.VaDENetEncoder'>, 'VaDENetVae': <class 'pynet.interfaces.VaDENetVae'>, 'VaDEPreTrainNetEncoder': <class 'pynet.interfaces.VaDEPreTrainNetEncoder'>, 'VaDEPreTrainNetVae': <class 'pynet.interfaces.VaDEPreTrainNetVae'>, 'VoxelMorphNetRegister': <class 'pynet.interfaces.VoxelMorphNetRegister'>}
classmethod get_registry()[source]
class pynet.interfaces.DenseNet121Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

growth_rate: int

how many filters to add each layer (‘k’ in paper).

block_config: 1-uplet

how many layers in each pooling block.

num_init_features: int

the number of filters to learn in the first convolution layer.

num_classes: int

number of classification classes.

bn_size: int, default 4

multiplicative factor for number of bottle neck layers (i.e. bn_size * k features in the bottleneck layer).

drop_rate: float, default 0

dropout rate after each dense layer.

memory_efficient: bool, default False

if True, uses checkpointing. Much more memory efficient, but slower.

class pynet.interfaces.DenseNet161Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

growth_rate: int

how many filters to add each layer (‘k’ in paper).

block_config: 1-uplet

how many layers in each pooling block.

num_init_features: int

the number of filters to learn in the first convolution layer.

num_classes: int

number of classification classes.

bn_size: int, default 4

multiplicative factor for number of bottle neck layers (i.e. bn_size * k features in the bottleneck layer).

drop_rate: float, default 0

dropout rate after each dense layer.

memory_efficient: bool, default False

if True, uses checkpointing. Much more memory efficient, but slower.

class pynet.interfaces.DenseNet169Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

growth_rate: int

how many filters to add each layer (‘k’ in paper).

block_config: 1-uplet

how many layers in each pooling block.

num_init_features: int

the number of filters to learn in the first convolution layer.

num_classes: int

number of classification classes.

bn_size: int, default 4

multiplicative factor for number of bottle neck layers (i.e. bn_size * k features in the bottleneck layer).

drop_rate: float, default 0

dropout rate after each dense layer.

memory_efficient: bool, default False

if True, uses checkpointing. Much more memory efficient, but slower.

class pynet.interfaces.DenseNet201Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

growth_rate: int

how many filters to add each layer (‘k’ in paper).

block_config: 1-uplet

how many layers in each pooling block.

num_init_features: int

the number of filters to learn in the first convolution layer.

num_classes: int

number of classification classes.

bn_size: int, default 4

multiplicative factor for number of bottle neck layers (i.e. bn_size * k features in the bottleneck layer).

drop_rate: float, default 0

dropout rate after each dense layer.

memory_efficient: bool, default False

if True, uses checkpointing. Much more memory efficient, but slower.

class pynet.interfaces.DenseNetClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

DenseNet.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

growth_rate: int

how many filters to add each layer (‘k’ in paper).

block_config: 1-uplet

how many layers in each pooling block.

num_init_features: int

the number of filters to learn in the first convolution layer.

num_classes: int

number of classification classes.

bn_size: int, default 4

multiplicative factor for number of bottle neck layers (i.e. bn_size * k features in the bottleneck layer).

drop_rate: float, default 0

dropout rate after each dense layer.

memory_efficient: bool, default False

if True, uses checkpointing. Much more memory efficient, but slower.

class pynet.interfaces.GMVAENetClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

The Gaussian Mixture VAE architecture.

Meta-GMVAE: Mixture of Gaussian VAE for Unsupervised Meta-Learning Dong Bok Lee, ICLR 2021.

Gaussian Mixture VAE: Lessons in Variational Inference, Generative Models, and Deep Nets: http://ruishu.io/2016/12/25/gmvae

Deep Unsupervised Clustering with Gaussian Mixture Variational Autoencoders Nat Dilokthanakul, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int

the number of mixture components.

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

dropout: float, default 0

define the dropout rate.

temperature: float, default 1

degree of how approximately discrete the distribution is. The closer to 0, the more discrete and the closer to infinity, the more uniform.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

prior_gmm: @callable, default None

a callable that implements the prior distribution p(z | y) Must accept as argument the y discrete variable and return a tf.distributions.MultivariateNormalDiag distribution.

decoder:

(@callable, default None) a callable that implements the generative distribution p(x | z). Must accept as arguments the encoded latent state z and return a subclass of tf.distributions.Distribution that can be used to evaluate the log_prob of the targets.

encoder_y:

(@callable, default None) a callable that implements the inference q(y | x) over the discrete latent variable y.

encoder_gmm:

(@callable, default None) a callable that implements the inference q(z | x, y) over the continuous latent variable z.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.GMVAENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

The Gaussian Mixture VAE architecture.

Meta-GMVAE: Mixture of Gaussian VAE for Unsupervised Meta-Learning Dong Bok Lee, ICLR 2021.

Gaussian Mixture VAE: Lessons in Variational Inference, Generative Models, and Deep Nets: http://ruishu.io/2016/12/25/gmvae

Deep Unsupervised Clustering with Gaussian Mixture Variational Autoencoders Nat Dilokthanakul, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int

the number of mixture components.

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

dropout: float, default 0

define the dropout rate.

temperature: float, default 1

degree of how approximately discrete the distribution is. The closer to 0, the more discrete and the closer to infinity, the more uniform.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

prior_gmm: @callable, default None

a callable that implements the prior distribution p(z | y) Must accept as argument the y discrete variable and return a tf.distributions.MultivariateNormalDiag distribution.

decoder:

(@callable, default None) a callable that implements the generative distribution p(x | z). Must accept as arguments the encoded latent state z and return a subclass of tf.distributions.Distribution that can be used to evaluate the log_prob of the targets.

encoder_y:

(@callable, default None) a callable that implements the inference q(y | x) over the discrete latent variable y.

encoder_gmm:

(@callable, default None) a callable that implements the inference q(z | x, y) over the continuous latent variable z.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.GMVAENetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

The Gaussian Mixture VAE architecture.

Meta-GMVAE: Mixture of Gaussian VAE for Unsupervised Meta-Learning Dong Bok Lee, ICLR 2021.

Gaussian Mixture VAE: Lessons in Variational Inference, Generative Models, and Deep Nets: http://ruishu.io/2016/12/25/gmvae

Deep Unsupervised Clustering with Gaussian Mixture Variational Autoencoders Nat Dilokthanakul, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int

the number of mixture components.

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

dropout: float, default 0

define the dropout rate.

temperature: float, default 1

degree of how approximately discrete the distribution is. The closer to 0, the more discrete and the closer to infinity, the more uniform.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

prior_gmm: @callable, default None

a callable that implements the prior distribution p(z | y) Must accept as argument the y discrete variable and return a tf.distributions.MultivariateNormalDiag distribution.

decoder:

(@callable, default None) a callable that implements the generative distribution p(x | z). Must accept as arguments the encoded latent state z and return a subclass of tf.distributions.Distribution that can be used to evaluate the log_prob of the targets.

encoder_y:

(@callable, default None) a callable that implements the inference q(y | x) over the discrete latent variable y.

encoder_gmm:

(@callable, default None) a callable that implements the inference q(z | x, y) over the continuous latent variable z.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.Inception3Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Inception v3 by Google.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

num_classes: int

number of classification classes.

aux_logits: bool, default False

auxiliary classifier for the training.

transform_input: bool, default False

normalize the data.

class pynet.interfaces.MCVAEEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Sparse Multi-Channel Variational Autoencoder (sMCVAE).

Sparse Multi-Channel Variational Autoencoder for the Joint Analysis of Heterogeneous Data, Luigi Antelmi, Nicholas Ayache, Philippe Robert, Marco Lorenzi Proceedings of the 36th International Conference on Machine Learning, PMLR 97:302-311, 2019.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

latent_dim: int

the number of latent dimensions.

n_channels: int

the number of channels.

n_feats: list of int

each channel input dimensions.

noise_init_logvar: float, default -3

default noise parameters values.

noise_fixed: bool, default False

if set not set do not required gradients on noise parameters.

sparse: bool, default False

use sparsity contraint.

vae_model: str, default “dense”

the VAE network used to encode each channel.

vae_kwargs: dict, default None

extra parameters passed initialization of the VAE model.

nodecoding: bool, default False

if set do not apply the decoding.

class pynet.interfaces.MCVAEVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Sparse Multi-Channel Variational Autoencoder (sMCVAE).

Sparse Multi-Channel Variational Autoencoder for the Joint Analysis of Heterogeneous Data, Luigi Antelmi, Nicholas Ayache, Philippe Robert, Marco Lorenzi Proceedings of the 36th International Conference on Machine Learning, PMLR 97:302-311, 2019.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

latent_dim: int

the number of latent dimensions.

n_channels: int

the number of channels.

n_feats: list of int

each channel input dimensions.

noise_init_logvar: float, default -3

default noise parameters values.

noise_fixed: bool, default False

if set not set do not required gradients on noise parameters.

sparse: bool, default False

use sparsity contraint.

vae_model: str, default “dense”

the VAE network used to encode each channel.

vae_kwargs: dict, default None

extra parameters passed initialization of the VAE model.

nodecoding: bool, default False

if set do not apply the decoding.

class pynet.interfaces.MOESimVAENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Implementation of a Mixture of Experts VAE with similarity constraint.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int, default 1

the number of components in the mixture prior. If 1, a classical VAE is generated with prior z ~ N(0, 1).

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

classifier_hidden_dims: list of int, default None

the sizes of the hidden layers of the classifier.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

dropout: float, default 0.5

define the dropout rate.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.MOESimVAENetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Implementation of a Mixture of Experts VAE with similarity constraint.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int, default 1

the number of components in the mixture prior. If 1, a classical VAE is generated with prior z ~ N(0, 1).

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

classifier_hidden_dims: list of int, default None

the sizes of the hidden layers of the classifier.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

dropout: float, default 0.5

define the dropout rate.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.NetParameters(**kwargs)[source]

Put all the networks parameters to this class. You can do this during the init or by setting instance parameters or both.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

class pynet.interfaces.NvNetSegmenter(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

NvNet: combination of Vnet and VAE (variation auto-encoder).

The variational auto-encoder branch reconstruct the input image jointly with segmentation in order to regularized the shared encoder.

Reference: https://arxiv.org/pdf/1810.11654.pdf. Code: https://github.com/athon2/BraTS2018_NvNet.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: uplet

the tensor data shape (X, Y, Z).

in_channels: int

number of channels in the input tensor.

num_classes: int

the number of features in the output segmentation map.

activation: str, default ‘relu’

the activation function.

normalization: str, default ‘group_normalization’

the normalization function.

mode: str, default ‘trilinear’

the interpolation mode.

with_vae: bool, default True

enable/disable vae penalty.

class pynet.interfaces.PMVAEEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

membership_mask: bool array (pathways, genes)

a binary mask encoding which genes belong to wich pathways.

latent_dim: int

the dimension of each module latent space.

hidden_layers: list of int

the dimension of each module encoder/decoder hidden layer.

bias_last_layer: bool, default False

use a bias term on the final decoder output.

add_auxiliary_module: bool, default True

include a fully connected pathway module.

terms: list of str (pathways, ), default None

the pathway names.

activation: klass, default None

the activation function.

class pynet.interfaces.PMVAEGenetic(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

membership_mask: bool array (pathways, genes)

a binary mask encoding which genes belong to wich pathways.

latent_dim: int

the dimension of each module latent space.

hidden_layers: list of int

the dimension of each module encoder/decoder hidden layer.

bias_last_layer: bool, default False

use a bias term on the final decoder output.

add_auxiliary_module: bool, default True

include a fully connected pathway module.

terms: list of str (pathways, ), default None

the pathway names.

activation: klass, default None

the activation function.

class pynet.interfaces.PMVAEVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

membership_mask: bool array (pathways, genes)

a binary mask encoding which genes belong to wich pathways.

latent_dim: int

the dimension of each module latent space.

hidden_layers: list of int

the dimension of each module encoder/decoder hidden layer.

bias_last_layer: bool, default False

use a bias term on the final decoder output.

add_auxiliary_module: bool, default True

include a fully connected pathway module.

terms: list of str (pathways, ), default None

the pathway names.

activation: klass, default None

the activation function.

class pynet.interfaces.PSPNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Pyramid Scene Parsing Network.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int, default 2

the number of features in the output segmentation map.

class pynet.interfaces.PSPNetSegmenter(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Pyramid Scene Parsing Network.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int, default 2

the number of features in the output segmentation map.

class pynet.interfaces.RCNetRegister(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

RCnet.

The recursive cascaded networks is a general architecture that enables learning deep cascades and can be used for deformable image registration. The cascade architecture is simple in design and can be built on any base network. The moving image is warped successively by each cascade and finally aligned to the fixed image; this procedure is recursive in a way that every cascade learns to perform a progressive deformation for the current warped image. The entire system is end-to-end and jointly trained in an unsupervised manner. Shared-weight techniques are developed in addition to the recursive architecture. Shared-weight cascading in training is not used since it consumes extra GPU memory.

We use the Dense Deformable Network (ADDNet) to estimate the affine transform in combination with a deformation field network estimator.

This network achieves state-of-the-art performance on both liver CT and brain MRI datasets for 3D medical image registration.

Reference: * https://arxiv.org/pdf/1907.12353 * https://arxiv.org/pdf/1902.05020

Code: * https://github.com/microsoft/Recursive-Cascaded-Networks.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: uplet

the tensor data shape (X, Y, Z).

in_channels: int

number of channels in the input tensor.

base_network: str

the name of the Network used to estimate the non-linear deformation.

n_cascades: int, default 1

the number of cascades.

rep: int, default 1

the number of times of shared-weight cascading.

class pynet.interfaces.ResAENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Restidual Auto-Encoder Network.

Reference: Discovering Functional Brain Networks with 3D Residual Autoencoder (ResAE), MICCAI 2020.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: uplet

the input tensor data shape (X, Y, Z).

cardinality: int, default 1

control the numbber of paths (ResNeXt architecture).

layers: 4-uplet, default [3, 4, 6, 3]

the layers blocks definition.

n_channels_in: int, default 1

the number of input channels.

decode: bool, default True

if set apply decoding.

class pynet.interfaces.ResNet101Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet101WideClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet101x32x8dClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet152Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet18Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet34Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet50Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet50WideClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNet50x32x4dClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.ResNetClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Residual Neural Network (ResNet) by Kaiming He et al.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

block: nn Module

one block architecture.

layers: 4-uplet

control the number of element in each layer.

num_classes: int

number of classification classes.

zero_init_residual: bool, default False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity.

groups: int, default 1

controls the connections between inputs and outputs during convolution.

width_per_group: int, default 64

control the number of input and output channels during convolution.

replace_stride_with_dilation: uplet, default None

each element in the tuple indicates if we should replace the 2x2 stride with a dilated convolution instead.

norm_layer: nn Module, default None

use the specified normalization module, by default use batch normalization.

class pynet.interfaces.STAAENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

SpatioTemporal Attention AutoEncoder (STAAE).

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input dimension.

nodecoding: bool, default False

if set do not apply the decoding.

class pynet.interfaces.SonoNetClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

SonoNet.

Feature extraction: the first 17 layers (counting max-pooling) of the VGG network is used to extract discriminant features (3 layers for the first 3 and 2 layers for the last 2 feature scales). Note that the number of filters are doubled after each of the first three max-pooling operations. Attention maps (adaptation module): the number of channels are first reduced to the number of target classes C. Subsequently, the spatial information is flattened via channel-wise global average pooling. Finally, a soft-max operation is applied to the resulting vector and the entry with maximum activation is selected as the prediction. As the network is constrained to classify based on the reduced vector, the network is forced to extract the most salient features for each class.

Reference: Attention-Gated Networksfor Improving Ultrasound Scan Plane Detection https://arxiv.org/pdf/1804.05338.pdf Code: https://github.com/ozan-oktay/Attention-Gated-Networks

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int

the number of features in the output segmentation map.

in_channels: int, default 1

number of channels in the input tensor.

n_convs: list of int, default [3, 3, 3, 2, 2]

the number of convolutions

start_filts: int, default 64

number of convolutional filters for the first conv.

batchnorm: bool, default False

normalize the inputs of the activation function.

nonlocal_mode: str, default ‘concatenation’

aggregation_mode: str, default ‘concat’

class pynet.interfaces.SphericalUNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Define the Spherical UNet structure.

https://github.com/zhaofenqiang/Spherical_U-Net Spherical U-Net on Cortical Surfaces: Methods and Applications

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

in_order: int

the input icosahedron order.

in_channels: int

input features/channels.

out_channels: int

output features/channels.

depth: int, default 5

number of layers in the UNet.

start_filts: int, default 32

number of convolutional filters for the first conv.

conv_mode: str, default ‘1ring’

the size of the spherical convolution filter: ‘1ring’ or ‘2ring’. Can also use rectangular grid projection: ‘repa’.

up_mode: str, default ‘interp’

type of upsampling: ‘transpose’ for transpose convolution (1 ring), ‘interp’ for nearest neighbor linear interpolation, ‘maxpad’ for max pooling shifted zero padding, and ‘zeropad’ for classical zero padding.

cachedir: str, default None

set tthis folder tu use smart caching speedup.

class pynet.interfaces.UNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

UNet.

The U-Net is a convolutional encoder-decoder neural network. Contextual spatial information (from the decoding, expansive pathway) about an input tensor is merged with information representing the localization of details (from the encoding, compressive pathway). Modifications to the original paper:

  • padding is used in 3x3x3 convolutions to prevent loss of border pixels

  • merging outputs does not require cropping due to (1)

  • residual connections can be used by specifying UNet(merge_mode=’add’)

  • if non-parametric upsampling is used in the decoder pathway (specified by upmode=’upsample’), then an additional 1x1x1 3d convolution occurs after upsampling to reduce channel dimensionality by a factor of 2. This channel halving happens with the convolution in the tranpose convolution (specified by upmode=’transpose’)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

num_classes: int

the number of features in the output segmentation map.

in_channels: int, default 1

number of channels in the input tensor.

depth: int, default 5

number of layers in the U-Net.

start_filts: int, default 64

number of convolutional filters for the first conv.

up_mode: string, default ‘transpose’

type of upconvolution. Choices: ‘transpose’ for transpose convolution, ‘upsample’ for nearest neighbour upsampling.

merge_mode: str, default ‘concat’

the skip connections merging strategy.

batchnorm: bool, default False

normalize the inputs of the activation function.

dim: str, default ‘3d’

‘3d’ or ‘2d’ input data.

input_shape: uplet

the tensor data shape (X, Y, Z) used during upsample (by default use a scale factor of 2).

class pynet.interfaces.UNetSegmenter(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

UNet.

The U-Net is a convolutional encoder-decoder neural network. Contextual spatial information (from the decoding, expansive pathway) about an input tensor is merged with information representing the localization of details (from the encoding, compressive pathway). Modifications to the original paper:

  • padding is used in 3x3x3 convolutions to prevent loss of border pixels

  • merging outputs does not require cropping due to (1)

  • residual connections can be used by specifying UNet(merge_mode=’add’)

  • if non-parametric upsampling is used in the decoder pathway (specified by upmode=’upsample’), then an additional 1x1x1 3d convolution occurs after upsampling to reduce channel dimensionality by a factor of 2. This channel halving happens with the convolution in the tranpose convolution (specified by upmode=’transpose’)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

num_classes: int

the number of features in the output segmentation map.

in_channels: int, default 1

number of channels in the input tensor.

depth: int, default 5

number of layers in the U-Net.

start_filts: int, default 64

number of convolutional filters for the first conv.

up_mode: string, default ‘transpose’

type of upconvolution. Choices: ‘transpose’ for transpose convolution, ‘upsample’ for nearest neighbour upsampling.

merge_mode: str, default ‘concat’

the skip connections merging strategy.

batchnorm: bool, default False

normalize the inputs of the activation function.

dim: str, default ‘3d’

‘3d’ or ‘2d’ input data.

input_shape: uplet

the tensor data shape (X, Y, Z) used during upsample (by default use a scale factor of 2).

class pynet.interfaces.VAEGMPNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)
Implementation of a Variational Autoencoder (VAE) with Gaussian

Mixture Prior (GMP).

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int, default 1

the number of components in the mixture prior. If 1, a classical VAE is generated with prior z ~ N(0, 1).

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

dropout: float, default 0

define the dropout rate.

encoder: @callable, default None

a distribution that implements inference q(z | x).

decoder: @callable, default None

a distribution that implements p(x | z). Must accept as arguments the latent state z and return a distribution that can be used to evaluate the log_prob of the targets.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.VAEGMPNetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)
Implementation of a Variational Autoencoder (VAE) with Gaussian

Mixture Prior (GMP).

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_dim: int

the input size.

latent_dim: int,

the size of the stochastic latent state of the GMVAE.

n_mix_components: int, default 1

the number of components in the mixture prior. If 1, a classical VAE is generated with prior z ~ N(0, 1).

dense_hidden_dims: list of int, default None

the sizes of the hidden layers of the fully connected network used to condition the distribution on the inputs. If None, then the default is a single-layered dense network.

sigma_min: float, default 0.001

the minimum value that the standard deviation of the distribution over the latent state can take.

raw_sigma_bias: float, default 0.25

a scalar that is added to the raw standard deviation output from the neural networks that parameterize the prior and approximate posterior. Useful for preventing standard deviations close to zero.

gen_bias_init: float, default 0

a bias to added to the raw output of the fully connected network that parameterizes the generative distribution. Useful for initalising the mean to a sensible starting point e.g. mean of training set.

dropout: float, default 0

define the dropout rate.

encoder: @callable, default None

a distribution that implements inference q(z | x).

decoder: @callable, default None

a distribution that implements p(x | z). Must accept as arguments the latent state z and return a distribution that can be used to evaluate the log_prob of the targets.

random_seed: int, default None

the seed for the random operations.

class pynet.interfaces.VAENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

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.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

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.

class pynet.interfaces.VAENetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

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.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

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.

class pynet.interfaces.VGG11Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

cfg: list

the model features: output channels number for convolution or ‘M’ for max pooling.

num_classes: int

the number of classes to predict.

batch_norm: bool, default False

use batch normalization after each convolution.

init_weights: bool, default True

initialize the model weights.

pretrained: str, default None

update the weights of the model using this state information.

make_layers: @func

a function to create the feature layers: default 2d max pooling with kernel size 2 and stride 2, and convolution with kernel size 3 and padding 1.

class pynet.interfaces.VGG13Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

cfg: list

the model features: output channels number for convolution or ‘M’ for max pooling.

num_classes: int

the number of classes to predict.

batch_norm: bool, default False

use batch normalization after each convolution.

init_weights: bool, default True

initialize the model weights.

pretrained: str, default None

update the weights of the model using this state information.

make_layers: @func

a function to create the feature layers: default 2d max pooling with kernel size 2 and stride 2, and convolution with kernel size 3 and padding 1.

class pynet.interfaces.VGG16Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

cfg: list

the model features: output channels number for convolution or ‘M’ for max pooling.

num_classes: int

the number of classes to predict.

batch_norm: bool, default False

use batch normalization after each convolution.

init_weights: bool, default True

initialize the model weights.

pretrained: str, default None

update the weights of the model using this state information.

make_layers: @func

a function to create the feature layers: default 2d max pooling with kernel size 2 and stride 2, and convolution with kernel size 3 and padding 1.

class pynet.interfaces.VGG19Classifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

cfg: list

the model features: output channels number for convolution or ‘M’ for max pooling.

num_classes: int

the number of classes to predict.

batch_norm: bool, default False

use batch normalization after each convolution.

init_weights: bool, default True

initialize the model weights.

pretrained: str, default None

update the weights of the model using this state information.

make_layers: @func

a function to create the feature layers: default 2d max pooling with kernel size 2 and stride 2, and convolution with kernel size 3 and padding 1.

class pynet.interfaces.VGGClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

VGGNet (2014) by Simonyan and Zisserman.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

cfg: list

the model features: output channels number for convolution or ‘M’ for max pooling.

num_classes: int

the number of classes to predict.

batch_norm: bool, default False

use batch normalization after each convolution.

init_weights: bool, default True

initialize the model weights.

pretrained: str, default None

update the weights of the model using this state information.

make_layers: @func

a function to create the feature layers: default 2d max pooling with kernel size 2 and stride 2, and convolution with kernel size 3 and padding 1.

class pynet.interfaces.VTNetRegister(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

VTNet.

Volume Tweening Network(VTN) consists of several cascaded registration subnetworks, after each of which the moving image is warped. The unsupervised training of network parameters is guided by the dissimilarity between the fixed image and each of the warped images, with the regularization losses on the flows predicted by the networks.

It follows an encoder-decoder architecture.

Reference: https://arxiv.org/pdf/1902.05020. Code: https://github.com/microsoft/Recursive-Cascaded-Networks.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

input_shape: uplet

the tensor data shape (X, Y, Z).

in_channels: int

number of channels in the input tensor.

kernel_size: int, default 3

the convolution kernels size (odd number).

padding: int, default 1

the padding size, recommended (kernel_size - 1) / 2

flow_multiplier: foat, default 1

weight the flow field by this factor.

nb_channels: int, default 16

the number of channels after the first convolution.

class pynet.interfaces.VaDENetClassifier(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Variational Deep Embedding (VaDE) Network.

Variational Deep Embedding: An Unsupervised and Generative Approach to Clustering, Zhuxi Jiang, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int the number of clusters. input_dim: int the dimension of observed data. latent_dim: int the dimension of latent space. hidden_dims: list of int, default [500, 500, 2000] the network hidden dimensions. binary: bool, default False apply sigmoid to get binary output. data: Tensor (N, M), default None data that can be used during display callbacks. labels: list of int (N, ), default None labels that can be used during display callbacks.

class pynet.interfaces.VaDENetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Variational Deep Embedding (VaDE) Network.

Variational Deep Embedding: An Unsupervised and Generative Approach to Clustering, Zhuxi Jiang, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int the number of clusters. input_dim: int the dimension of observed data. latent_dim: int the dimension of latent space. hidden_dims: list of int, default [500, 500, 2000] the network hidden dimensions. binary: bool, default False apply sigmoid to get binary output. data: Tensor (N, M), default None data that can be used during display callbacks. labels: list of int (N, ), default None labels that can be used during display callbacks.

class pynet.interfaces.VaDENetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Variational Deep Embedding (VaDE) Network.

Variational Deep Embedding: An Unsupervised and Generative Approach to Clustering, Zhuxi Jiang, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

n_classes: int the number of clusters. input_dim: int the dimension of observed data. latent_dim: int the dimension of latent space. hidden_dims: list of int, default [500, 500, 2000] the network hidden dimensions. binary: bool, default False apply sigmoid to get binary output. data: Tensor (N, M), default None data that can be used during display callbacks. labels: list of int (N, ), default None labels that can be used during display callbacks.

class pynet.interfaces.VaDEPreTrainNetEncoder(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Auto-Encoder for pretraining VaDE.

Variational Deep Embedding: An Unsupervised and Generative Approach to Clustering, Zhuxi Jiang, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

model: VaDE

the model.

class pynet.interfaces.VaDEPreTrainNetVae(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

Auto-Encoder for pretraining VaDE.

Variational Deep Embedding: An Unsupervised and Generative Approach to Clustering, Zhuxi Jiang, arXiv 2017.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

model: VaDE

the model.

class pynet.interfaces.VoxelMorphNetRegister(net_params=None, pretrained=None, resume=False, add_labels=False, optimizer_name='Adam', learning_rate=0.001, loss_name='NLLLoss', metrics=None, use_cuda=False, **kwargs)

VoxelMorphNet.

An unsupervised learning-based inference algorithm that uses insights from classical registration methods and makes use of recent developments inconvolutional neural networks (CNNs).

VoxelMorph assumes that input images are pre-affined by an external tool.

2018 CVPR implementation of voxelmorph.

TODO: expand this model by including anatomical surface alignment, which enables training the network given (optional) anatomical segmentations -> described in the paper.

Reference: https://arxiv.org/abs/1903.03545. Code: https://github.com/voxelmorph/voxelmorph.

See the ‘DeepLearningInterface’ documentation for the documentation of the generic parameters. The network parameters are discribed in the following section.

Attributes

vol_size: uplet

volume size of the atlas.

enc_nf: list of int, default [16, 32, 32, 32]

the number of features maps for encoding stages.

dec_nf: int, default [32, 32, 32, 32, 32, 16, 16]

the number of features maps for decoding stages.

full_size: bool, default False

full amount of decoding layers.

pynet.interfaces.get_interfaces(family=None)[source]

List/sort all available Deep Learning training interfaces.

Parameters

family: str or list of str, default None

the interfaces family name.

Returns

interfaces: dict

the requested interfaces.

Follow us

© 2019, pynet developers .
Inspired by AZMIND template.