niftynet.network.unet_2d module

class UNet2D(num_classes, w_initializer=None, w_regularizer=None, b_initializer=None, b_regularizer=None, acti_func='relu', name='UNet2D')[source]

Bases: niftynet.network.base_net.BaseNet

### Description
A reimplementation of 2D UNet:
Ronneberger et al., U-Net: Convolutional Networks for Biomedical Image Segmentation, MICCAI ‘15

### Building blocks [dBLOCK] - Downsampling Block (conv 3x3, Relu + conv 3x3, Relu + Max pooling) [BLOCK] - Two layer Block (conv 3x3, Relu + conv 3x3, Relu) [uBLOCK] - Upsampling Block (deconv 2x2 + crop and concat + conv 3x3, Relu + conv 3x3, Relu) [CONV] - Classification block (conv 1x1)

### Diagram

INPUT –> [dBLOCK] - - - - - - - - - - - - - - - - [BLOCK] –> [CONV] –> OUTPUT
[dBLOCK] - - - - - - - - - - - - [uBLOCK]
[dBLOCK] - - - - - - - [uBLOCK]
[dBLOCK] - - - [uBLOCK]

—-[BLOCk] —-

### Constraints

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 – other conditional arguments, not in use
Returns:

tensor, output of the network

class TwoLayerConv(n_chns, conv_params)[source]

Bases: niftynet.layer.base_layer.TrainableLayer

Two convolutional layers, number of output channels are n_chns for both of them.

–conv–conv–

layer_op(input_tensor, is_training=None)[source]
Parameters:
  • input_tensor – tensor, input to the two layer convolution
  • is_training – flag for training
Returns:

tensor, output of –conv–conv

class CropConcat(name='crop_concat')[source]

Bases: niftynet.layer.base_layer.Layer

This layer concatenates two input tensors, the first one is cropped and resized to match the second one.

This layer assumes the same amount of differences in every spatial dimension in between the two tensors.

layer_op(tensor_a, tensor_b)[source]

match the spatial shape and concatenate the tensors tensor_a will be cropped and resized to match tensor_b.

Parameters:
  • tensor_a – tensor, input
  • tensor_b – tensor, input
Returns:

concatenated tensor