class_docstr: implementation of HighRes3DNet:
    Li et al., "On the compactness, efficiency, and representation of 3D
    convolutional networks: Brain parcellation as a pretext task", IPMI '17
  
    ### Building blocks
  
    {   }       -  Residual connections: see He et al. "Deep residual learning for
                                                        image recognition", in CVPR '16
  
    [CONV]      -  Convolutional layer in form: Activation(Convolution(X))
                   where X = input tensor or output of previous layer
  
                   and Activation is a function which includes:
  
                      a) Batch-Norm
                      b) Activation Function (ReLu, PreLu, Sigmoid, Tanh etc.)
                      c) Drop-out layer by sampling random variables from a Bernouilli distribution
                         if p < 1
  
    [CONV*]      - Convolutional layer with no activation function
  
    (r)[D-CONV(d)] - Convolutional layer with dilated convolutions with blocks in
                   pre-activation mode: D-Convolution(Activation(X))
                   see He et al., "Identity Mappings in Deep Residual Networks", ECCV '16
  
                   dilation factor = d
                   D-CONV(2) : dilated convolution with dilation factor 2
  
                   repeat factor = r
                   e.g.
                   (2)[D-CONV(d)]     : 2 dilated convolutional layers in a row [D-CONV] -> [D-CONV]
                   { (2)[D-CONV(d)] } : 2 dilated convolutional layers within residual block
  
  ### Diagram
  
  INPUT --> [CONV] --> { (3)[D-CONV(1)] } --> { (3)[D-CONV(2)] } --> { (3)[D-CONV(4)] } -> [CONV*] -> Loss
  
  ### Constraints
  - Input image size should be divisible by 8
class_docstr_tok: ["implementation","of","HighRes3DNet",":","Li","et","al.",",","``","On","the","compactness",",","efficiency",",","and","representation","of","3D","convolutional","networks",":","Brain","parcellation","as","a","pretext","task","''",",","IPMI","'17","#","#","#","Building","blocks","{","}","-","Residual","connections",":","see","He","et","al",".","``","Deep","residual","learning","for","image","recognition","''",",","in","CVPR","'16","[","CONV","]","-","Convolutional","layer","in","form",":","Activation","(","Convolution","(","X",")",")","where","X","=","input","tensor","or","output","of","previous","layer","and","Activation","is","a","function","which","includes",":","a",")","Batch-Norm","b",")","Activation","Function","(","ReLu",",","PreLu",",","Sigmoid",",","Tanh","etc",".",")","c",")","Drop-out","layer","by","sampling","random","variables","from","a","Bernouilli","distribution","if","p","<","1","[","CONV","*","]","-","Convolutional","layer","with","no","activation","function","(","r",")","[","D-CONV","(","d",")","]","-","Convolutional","layer","with","dilated","convolutions","with","blocks","in","pre-activation","mode",":","D-Convolution","(","Activation","(","X",")",")","see","He","et","al.",",","``","Identity","Mappings","in","Deep","Residual","Networks","''",",","ECCV","'16","dilation","factor","=","d","D-CONV","(","2",")",":","dilated","convolution","with","dilation","factor","2","repeat","factor","=","r","e.g",".","(","2",")","[","D-CONV","(","d",")","]",":","2","dilated","convolutional","layers","in","a","row","[","D-CONV","]","-",">","[","D-CONV","]","{","(","2",")","[","D-CONV","(","d",")","]","}",":","2","dilated","convolutional","layers","within","residual","block","#","#","#","Diagram","INPUT","--",">","[","CONV","]","--",">","{","(","3",")","[","D-CONV","(","1",")","]","}","--",">","{","(","3",")","[","D-CONV","(","2",")","]","}","--",">","{","(","3",")","[","D-CONV","(","4",")","]","}","-",">","[","CONV","*","]","-",">","Loss","#","#","#","Constraints","-","Input","image","size","should","be","divisible","by","8"]
docstr: :param num_classes: int, number of channels of output
  :param w_initializer: weight initialisation for network
  :param w_regularizer: weight regularisation for network
  :param b_initializer: bias initialisation for network
  :param b_regularizer: bias regularisation for network
  :param acti_func: activation function to use
  :param name: layer name
docstr_tok: [":","param","num_classes",":","int",",","number","of","channels","of","output",":","param","w_initializer",":","weight","initialisation","for","network",":","param","w_regularizer",":","weight","regularisation","for","network",":","param","b_initializer",":","bias","initialisation","for","network",":","param","b_regularizer",":","bias","regularisation","for","network",":","param","acti_func",":","activation","function","to","use",":","param","name",":","layer","name"]
code: def __init__(
      self,
      num_classes,
      w_initializer=None,
      w_regularizer=None,
      b_initializer=None,
      b_regularizer=None,
      acti_func="prelu",
      name="HighRes3DNet",
  ):
      """
  
      :param num_classes: int, number of channels of output
      :param w_initializer: weight initialisation for network
      :param w_regularizer: weight regularisation for network
      :param b_initializer: bias initialisation for network
      :param b_regularizer: bias regularisation for network
      :param acti_func: activation function to use
      :param name: layer name
      """
  
      super(HighRes3DNet, self).__init__(
          num_classes=num_classes,
          w_initializer=w_initializer,
          w_regularizer=w_regularizer,
          b_initializer=b_initializer,
          b_regularizer=b_regularizer,
          acti_func=acti_func,
          name=name,
      )
  
      self.layers = [
          {"name": "conv_0", "n_features": 16, "kernel_size": 3},
          {
              "name": "res_1",
              "n_features": 16,
              "kernels": (3, 3),
              "repeat": 3,
          },
          {
              "name": "res_2",
              "n_features": 32,
              "kernels": (3, 3),
              "repeat": 3,
          },
          {
              "name": "res_3",
              "n_features": 64,
              "kernels": (3, 3),
              "repeat": 3,
          },
          {"name": "conv_1", "n_features": 80, "kernel_size": 1},
          {
              "name": "conv_2",
              "n_features": num_classes,
              "kernel_size": 1,
          },
      ]
  
file_path: NiftyNet/niftynet/network/highres3dnet.py
imports: from __future__ import absolute_import, print_function
  from six.moves import range
  from niftynet.layer import layer_util
  from niftynet.layer.activation import ActiLayer
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.bn import BNLayer
  from niftynet.layer.convolution import ConvLayer, ConvolutionalLayer
  from niftynet.layer.dilatedcontext import DilatedTensor
  from niftynet.layer.elementwise import ElementwiseLayer
  from niftynet.network.base_net import BaseNet
label_desc: Use image node_id 1 to create a new HighRes3DNet object from inherited base classes: BaseNet with example: obj = HighRes3DNet(num_classes, w_initializer, w_regularizer, b_initializer, b_regularizer, acti_func, name)