niftynet.network.se_resnet module

class SE_ResNetDesc(bn, fc, conv1, blocks)

Bases: tuple

blocks

Alias for field number 3

bn

Alias for field number 0

conv1

Alias for field number 2

fc

Alias for field number 1

class SE_ResNet(num_classes, n_features=[16, 64, 128], n_blocks_per_resolution=1, w_initializer=None, w_regularizer=None, b_initializer=None, b_regularizer=None, acti_func='relu', name='SE_ResNet')[source]

Bases: niftynet.network.base_net.BaseNet

### Description
implementation of Res-Net:
He et al., “Identity Mappings in Deep Residual Networks”, arXiv:1603.05027v3

### Building Blocks [CONV] - Convolutional layer, no activation, no batch norm (s)[DOWNRES] - Downsample residual block.

Each block is composed of a first bottleneck block with stride s, followed by n_blocks_per_resolution bottleneck blocks with stride 1. Bottleneck blocks include a squeeze-and-excitation block

[FC] - Fully connected layer with nr output channels == num_classes

### Diagram

INPUT –> [CONV] –>(s=1)[DOWNRES] –> (s=2)[DOWNRES] –> BN, ReLU, mean –> [FC] –> OUTPUT

### Constraints

__init__(num_classes, n_features=[16, 64, 128], n_blocks_per_resolution=1, w_initializer=None, w_regularizer=None, b_initializer=None, b_regularizer=None, acti_func='relu', name='SE_ResNet')[source]
Parameters:
  • num_classes – int, number of channels of output
  • n_features – array, number of features per ResNet block
  • n_blocks_per_resolution – int, number of BottleneckBlock per DownResBlock
  • w_initializer – weight initialisation for network
  • w_regularizer – weight regularisation for network
  • b_initializer – bias initialisation for network
  • b_regularizer – bias regularisation for network
  • acti_func – ctivation function to use
  • name – layer name
create()[source]
Returns:tuple with batch norm layer, fully connected layer, first conv layer and all residual blocks
layer_op(images, is_training=True, **unused_kwargs)[source]
Parameters:
  • images – tensor, input to the network
  • is_training – boolean, True if network is in training mode
  • unused_kwargs – not in use
Returns:

tensor, output of the final fully connected layer

class BottleneckBlockDesc1(conv)

Bases: tuple

conv

Alias for field number 0

class BottleneckBlockDesc2(common_bn, conv, conv_shortcut)

Bases: tuple

common_bn

Alias for field number 0

conv

Alias for field number 1

conv_shortcut

Alias for field number 2

class BottleneckBlock(n_output_chns, stride, Conv, name='bottleneck')[source]

Bases: niftynet.layer.base_layer.TrainableLayer

__init__(n_output_chns, stride, Conv, name='bottleneck')[source]
Parameters:
  • n_output_chns – int, number of output channels
  • stride – int, stride to use in the convolutional layers
  • Conv – layer, convolutional layer
  • name – layer name
create(input_chns)[source]
Parameters:input_chns – int, number of input channel
Returns:tuple, with series of convolutional layers
layer_op(images, is_training=True)[source]
Parameters:
  • images – tensor, input to the BottleNeck block
  • is_training – boolean, True if network is in training mode
Returns:

tensor, output of the BottleNeck block

class DownResBlockDesc(blocks)

Bases: tuple

blocks

Alias for field number 0

class DownResBlock(n_output_chns, count, stride, Conv, name='downres')[source]

Bases: niftynet.layer.base_layer.TrainableLayer

__init__(n_output_chns, count, stride, Conv, name='downres')[source]
Parameters:
  • n_output_chns – int, number of output channels
  • count – int, number of BottleneckBlocks to generate
  • stride – int, stride for convolutional layer
  • Conv – Layer, convolutional layer
  • name – layer name
create()[source]
Returns:tuple, containing all the Bottleneck blocks composing the DownRes block
layer_op(images, is_training)[source]
Parameters:
  • images – tensor, input to the DownRes block
  • is_training – is_training: boolean, True if network is in training mode
Returns:

tensor, output of the DownRes block