Block Construct

The block construct is similar to the architecture construct in that it requires input, output, and neuralflow blocks. However, it also contains a params block, where the user can define parameters to pass to the layer they are defining. Consider the following example, which defines a residual identity block (one of the components of ResNet):

block: residual_identity_block
  input: in ;
  output: out ;
  params: k, nbf1, nbf2, nbf3 ;

  in -> Conv2D: [nbf1, 1]
    -> BatchNormalization: []
    -> Activation: ['relu'] -> x

  x -> Conv2D: [nbf2, k, padding='same']
    -> BatchNormalization: []
    -> Activation: ['relu'] -> x

  x -> Conv2D: [nbf3, 1]
    -> BatchNormalization: []
    -> x

  [x, inp] -> Merge: [mode="sum"]
           -> Activation: ['relu']
           -> out ;

The input and output block just define variables, representing the input and output to the residual_identity_block layer.

The params block defines four parameters that must be specified when calling this block:

params: k, nbf1, nbf2, nbf3;

The neuralflow is defined in the same way as in the architecture construct.

This block can then be saved in an .nml script, and imported into a training script using the import keyword:

import "/DM-Dash/library/res_identity.nml"

This layer then be used in an architecture neuralflow, specifying values for the parameters.

-> residual_identity_block[3, 64, 256, 128] ->