parameters: (units, num_stages, filter_list, num_classes, image_shape, bottle_neck=True, bn_mom=0.9, workspace=256, dtype='float32', memonger=False)
return_statement: return mx.sym.SoftmaxOutput(data=fc1, name='softmax')
docstring: Return ResNet symbol of
      Parameters
      ----------
      units : list
          Number of units in each stage
      num_stages : int
          Number of stage
      filter_list : list
          Channel size of each stage
      num_classes : int
          Ouput size of symbol
      dataset : str
          Dataset type, only cifar10 and imagenet supports
      workspace : int
          Workspace used in convolution operator
      dtype : str
          Precision (float32 or float16)
docstring_summary: Return ResNet symbol of
      Parameters
      ----------
      units : list
          Number of units in each stage
      num_stages : int
          Number of stage
      filter_list : list
          Channel size of each stage
      num_classes : int
          Ouput size of symbol
      dataset : str
          Dataset type, only cifar10 and imagenet supports
      workspace : int
          Workspace used in convolution operator
      dtype : str
          Precision (float32 or float16)
docstring_tokens: Return ResNet symbol of Parameters ---------- units : list Number of units in each stage num_stages : int Number of stage filter_list : list Channel size of each stage num_classes : int Ouput size of symbol dataset : str Dataset type only cifar10 and imagenet supports workspace : int Workspace used in convolution operator dtype : str Precision ( float32 or float16 )
function: def resnet(units, num_stages, filter_list, num_classes, image_shape, bottle_neck=True, bn_mom=0.9, workspace=256, dtype='float32', memonger=False):
      """Return ResNet symbol of
      Parameters
      ----------
      units : list
          Number of units in each stage
      num_stages : int
          Number of stage
      filter_list : list
          Channel size of each stage
      num_classes : int
          Ouput size of symbol
      dataset : str
          Dataset type, only cifar10 and imagenet supports
      workspace : int
          Workspace used in convolution operator
      dtype : str
          Precision (float32 or float16)
      """
      num_unit = len(units)
      assert(num_unit == num_stages)
      data = mx.sym.Variable(name='data')
      if dtype == 'float32':
          data = mx.sym.identity(data=data, name='id')
      else:
          if dtype == 'float16':
              data = mx.sym.Cast(data=data, dtype=np.float16)
      data = mx.sym.BatchNorm(data=data, fix_gamma=True, eps=2e-5, momentum=bn_mom, name='bn_data')
      (nchannel, height, width) = image_shape
      if height <= 32:            # such as cifar10
          body = mx.sym.Convolution(data=data, num_filter=filter_list[0], kernel=(3, 3), stride=(1,1), pad=(1, 1),
                                    no_bias=True, name="conv0", workspace=workspace)
      else:                       # often expected to be 224 such as imagenet
          body = mx.sym.Convolution(data=data, num_filter=filter_list[0], kernel=(7, 7), stride=(2,2), pad=(3, 3),
                                    no_bias=True, name="conv0", workspace=workspace)
          body = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn0')
          body = mx.sym.Activation(data=body, act_type='relu', name='relu0')
          body = mx.sym.Pooling(data=body, kernel=(3, 3), stride=(2,2), pad=(1,1), pool_type='max')
  
      for i in range(num_stages):
          body = residual_unit(body, filter_list[i+1], (1 if i==0 else 2, 1 if i==0 else 2), False,
                               name='stage%d_unit%d' % (i + 1, 1), bottle_neck=bottle_neck, workspace=workspace,
                               memonger=memonger)
          for j in range(units[i]-1):
              body = residual_unit(body, filter_list[i+1], (1,1), True, name='stage%d_unit%d' % (i + 1, j + 2),
                                   bottle_neck=bottle_neck, workspace=workspace, memonger=memonger)
      bn1 = mx.sym.BatchNorm(data=body, fix_gamma=False, eps=2e-5, momentum=bn_mom, name='bn1')
      relu1 = mx.sym.Activation(data=bn1, act_type='relu', name='relu1')
      # Although kernel is not used here when global_pool=True, we should put one
      pool1 = mx.sym.Pooling(data=relu1, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1')
      flat = mx.sym.Flatten(data=pool1)
      fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='fc1')
      if dtype == 'float16':
          fc1 = mx.sym.Cast(data=fc1, dtype=np.float32)
      return mx.sym.SoftmaxOutput(data=fc1, name='softmax')
function_tokens: def resnet ( units , num_stages , filter_list , num_classes , image_shape , bottle_neck = True , bn_mom = 0.9 , workspace = 256 , dtype = 'float32' , memonger = False ) : num_unit = len ( units ) assert ( num_unit == num_stages ) data = mx . sym . Variable ( name = 'data' ) if dtype == 'float32' : data = mx . sym . identity ( data = data , name = 'id' ) else : if dtype == 'float16' : data = mx . sym . Cast ( data = data , dtype = np . float16 ) data = mx . sym . BatchNorm ( data = data , fix_gamma = True , eps = 2e-5 , momentum = bn_mom , name = 'bn_data' ) ( nchannel , height , width ) = image_shape if height <= 32 : # such as cifar10 body = mx . sym . Convolution ( data = data , num_filter = filter_list [ 0 ] , kernel = ( 3 , 3 ) , stride = ( 1 , 1 ) , pad = ( 1 , 1 ) , no_bias = True , name = "conv0" , workspace = workspace ) else : # often expected to be 224 such as imagenet body = mx . sym . Convolution ( data = data , num_filter = filter_list [ 0 ] , kernel = ( 7 , 7 ) , stride = ( 2 , 2 ) , pad = ( 3 , 3 ) , no_bias = True , name = "conv0" , workspace = workspace ) body = mx . sym . BatchNorm ( data = body , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = 'bn0' ) body = mx . sym . Activation ( data = body , act_type = 'relu' , name = 'relu0' ) body = mx . sym . Pooling ( data = body , kernel = ( 3 , 3 ) , stride = ( 2 , 2 ) , pad = ( 1 , 1 ) , pool_type = 'max' ) for i in range ( num_stages ) : body = residual_unit ( body , filter_list [ i + 1 ] , ( 1 if i == 0 else 2 , 1 if i == 0 else 2 ) , False , name = 'stage%d_unit%d' % ( i + 1 , 1 ) , bottle_neck = bottle_neck , workspace = workspace , memonger = memonger ) for j in range ( units [ i ] - 1 ) : body = residual_unit ( body , filter_list [ i + 1 ] , ( 1 , 1 ) , True , name = 'stage%d_unit%d' % ( i + 1 , j + 2 ) , bottle_neck = bottle_neck , workspace = workspace , memonger = memonger ) bn1 = mx . sym . BatchNorm ( data = body , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = 'bn1' ) relu1 = mx . sym . Activation ( data = bn1 , act_type = 'relu' , name = 'relu1' ) # Although kernel is not used here when global_pool=True, we should put one pool1 = mx . sym . Pooling ( data = relu1 , global_pool = True , kernel = ( 7 , 7 ) , pool_type = 'avg' , name = 'pool1' ) flat = mx . sym . Flatten ( data = pool1 ) fc1 = mx . sym . FullyConnected ( data = flat , num_hidden = num_classes , name = 'fc1' ) if dtype == 'float16' : fc1 = mx . sym . Cast ( data = fc1 , dtype = np . float32 ) return mx . sym . SoftmaxOutput ( data = fc1 , name = 'softmax' )