(inputs,
                        is_training,
                        scope,
                        weight_decay,
                        reuse=tf.AUTO_REUSE,
                        params=None,
                        moments=None,
                        depth_multiplier=1.0,
                        backprop_through_moments=True,
                        use_bounded_activation=False,
                        keep_spatial_dims=False)
A four-layer-convnet architecture.
A four-layer-convnet architecture.
A four - layer - convnet architecture .
def _four_layer_convnet(inputs,
                        is_training,
                        scope,
                        weight_decay,
                        reuse=tf.AUTO_REUSE,
                        params=None,
                        moments=None,
                        depth_multiplier=1.0,
                        backprop_through_moments=True,
                        use_bounded_activation=False,
                        keep_spatial_dims=False):
  """A four-layer-convnet architecture."""
  layer = tf.stop_gradient(inputs)
  model_params_keys, model_params_vars = [], []
  moments_keys, moments_vars = [], []

  with tf.variable_scope(scope, reuse=reuse):
    for i in range(4):
      with tf.variable_scope('layer_{}'.format(i), reuse=reuse):
        depth = int(64 * depth_multiplier)
        layer, conv_bn_params, conv_bn_moments = conv_bn(
            layer, [3, 3],
            depth,
            stride=1,
            weight_decay=weight_decay,
            params=params,
            moments=moments,
            is_training=is_training,
            backprop_through_moments=backprop_through_moments)
        model_params_keys.extend(conv_bn_params.keys())
        model_params_vars.extend(conv_bn_params.values())
        moments_keys.extend(conv_bn_moments.keys())
        moments_vars.extend(conv_bn_moments.values())

      if use_bounded_activation:
        layer = tf.nn.relu6(layer)
      else:
        layer = tf.nn.relu(layer)
      layer = tf.layers.max_pooling2d(layer, [2, 2], 2)
      logging.info('Output of block %d: %s', i, layer.shape)

    model_params = collections.OrderedDict(
        zip(model_params_keys, model_params_vars))
    moments = collections.OrderedDict(zip(moments_keys, moments_vars))
    if not keep_spatial_dims:
      layer = tf.layers.flatten(layer)
    return_dict = {
        'embeddings': layer,
        'params': model_params,
        'moments': moments
    }

    return return_dict
def _four_layer_convnet ( inputs , is_training , scope , weight_decay , reuse = tf . AUTO_REUSE , params = None , moments = None , depth_multiplier = 1.0 , backprop_through_moments = True , use_bounded_activation = False , keep_spatial_dims = False ) : layer = tf . stop_gradient ( inputs ) model_params_keys , model_params_vars = [ ] , [ ] moments_keys , moments_vars = [ ] , [ ] with tf . variable_scope ( scope , reuse = reuse ) : for i in range ( 4 ) : with tf . variable_scope ( 'layer_{}' . format ( i ) , reuse = reuse ) : depth = int ( 64 * depth_multiplier ) layer , conv_bn_params , conv_bn_moments = conv_bn ( layer , [ 3 , 3 ] , depth , stride = 1 , weight_decay = weight_decay , params = params , moments = moments , is_training = is_training , backprop_through_moments = backprop_through_moments ) model_params_keys . extend ( conv_bn_params . keys ( ) ) model_params_vars . extend ( conv_bn_params . values ( ) ) moments_keys . extend ( conv_bn_moments . keys ( ) ) moments_vars . extend ( conv_bn_moments . values ( ) ) if use_bounded_activation : layer = tf . nn . relu6 ( layer ) else : layer = tf . nn . relu ( layer ) layer = tf . layers . max_pooling2d ( layer , [ 2 , 2 ] , 2 ) logging . info ( 'Output of block %d: %s' , i , layer . shape ) model_params = collections . OrderedDict ( zip ( model_params_keys , model_params_vars ) ) moments = collections . OrderedDict ( zip ( moments_keys , moments_vars ) ) if not keep_spatial_dims : layer = tf . layers . flatten ( layer ) return_dict = { 'embeddings' : layer , 'params' : model_params , 'moments' : moments } return return_dict