def get_real_filter(layers, img_size):
 real_filter = np.zeros((len(layers), 2))
 conv_mode = True
 first_conv_layer = True
 expon = np.ones((1, 2))
 for (i, layer) in enumerate(layers[1:]):
  j = (i + 1)
  if (not conv_mode):
   real_filter[j] = img_size
   continue
  if is_conv2d(layer):
   if (not first_conv_layer):
    new_filter = (np.array(layer.filter_size) * expon)
    real_filter[j] = new_filter
   else:
    new_filter = (np.array(layer.filter_size) * expon)
    real_filter[j] = new_filter
    first_conv_layer = False
  elif is_maxpool2d(layer):
   real_filter[j] = real_filter[i]
   expon *= np.array(layer.pool_size)
  else:
   conv_mode = False
   real_filter[j] = img_size
 real_filter[0] = img_size
 return real_filter

def get_real_filter ( layers , img_size ) : real_filter = np . zeros ( ( len ( layers ) , 2 ) ) conv_mode = True first_conv_layer = True expon = np . ones ( ( 1 , 2 ) ) for ( i , layer ) in enumerate ( layers [ 1 : ] ) : j = ( i + 1 ) if ( not conv_mode ) : real_filter [ j ] = img_size continue if is_conv2d ( layer ) : if ( not first_conv_layer ) : new_filter = ( np . array ( layer . filter_size ) * expon ) real_filter [ j ] = new_filter else : new_filter = ( np . array ( layer . filter_size ) * expon ) real_filter [ j ] = new_filter first_conv_layer = False elif is_maxpool2d ( layer ) : real_filter [ j ] = real_filter [ i ] expon *= np . array ( layer . pool_size ) else : conv_mode = False real_filter [ j ] = img_size real_filter [ 0 ] = img_size return real_filter
get the real filter sizes of each layer involved in convoluation .