Menu

Helper Module for Deep Learning.

Sononet is a CNN architecture with two components: a feature extractor module and an adaptation module.

class pynet.models.sononet.Conv2(in_size, out_size, is_batchnorm, n=2, ks=3, stride=1, padding=1)[source]
__init__(in_size, out_size, is_batchnorm, n=2, ks=3, stride=1, padding=1)[source]

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

forward(inputs)[source]
class pynet.models.sononet.Conv3(in_size, out_size, is_batchnorm, kernel_size=(3, 3, 1), padding_size=(1, 1, 0), init_stride=(1, 1, 1))[source]
__init__(in_size, out_size, is_batchnorm, kernel_size=(3, 3, 1), padding_size=(1, 1, 0), init_stride=(1, 1, 1))[source]

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

forward(inputs)[source]
class pynet.models.sononet.GridAttentionBlock2D(in_channels, gating_channels, inter_channels=None, mode='concatenation', sub_sample_factor=(1, 1), bn_layer=True, use_W=True, use_phi=True, use_theta=True, use_psi=True, nonlinearity1='relu')[source]
__init__(in_channels, gating_channels, inter_channels=None, mode='concatenation', sub_sample_factor=(1, 1), bn_layer=True, use_W=True, use_phi=True, use_theta=True, use_psi=True, nonlinearity1='relu')[source]

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

class pynet.models.sononet.GridAttentionBlock3D(in_channels, gating_channels, inter_channels=None, mode='concatenation', sub_sample_factor=(1, 1, 1), bn_layer=True)[source]
__init__(in_channels, gating_channels, inter_channels=None, mode='concatenation', sub_sample_factor=(1, 1, 1), bn_layer=True)[source]

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

class pynet.models.sononet.SonoNet(n_classes, in_channels=1, n_convs=[3, 3, 3, 2, 2], start_filts=64, batchnorm=True, nonlocal_mode='concatenation', aggregation_mode='concat')[source]

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

__init__(n_classes, in_channels=1, n_convs=[3, 3, 3, 2, 2], start_filts=64, batchnorm=True, nonlocal_mode='concatenation', aggregation_mode='concat')[source]

Init class.

Parameters

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’

static aggregate_output(output, aggregation='mean', aggregation_weight=[1, 1, 1], idx=0)[source]

Given a list of predictions from the model, make a decision based on aggreagation rules.

aggregation_concat(*attended_maps)[source]
aggregation_ds(*attended_maps)[source]
aggregation_ft(*attended_maps)[source]
aggregation_sep(*attended_maps)[source]
static apply_softmax(pred)[source]
debug(name, tensor)[source]
forward(inputs)[source]
pynet.models.sononet.init_weights(net, init_type='normal')[source]
pynet.models.sononet.weights_init_kaiming(m)[source]
pynet.models.sononet.weights_init_normal(m)[source]
pynet.models.sononet.weights_init_orthogonal(m)[source]
pynet.models.sononet.weights_init_xavier(m)[source]

Follow us

© 2019, pynet developers .
Inspired by AZMIND template.