(inputs,
                            is_training,
                            weight_decay,
                            params=None,
                            moments=None,
                            n_hidden_units=(64,),
                            use_batchnorm=False,
                            reuse=tf.AUTO_REUSE,
                            scope='fully_connected',
                            use_bounded_activation=False,
                            backprop_through_moments=None,
                            keep_spatial_dims=None)
return return_dict
A fully connected linear network.

  Args:
    inputs: Tensor of shape [None, num_features], where `num_features` is the
      number of input features.
    is_training: whether it's train or test mode (for batch norm).
    weight_decay: float, scaling constant for L2 weight decay on weight
      variables.
    params: None will create new params (or reuse from scope), otherwise an
      ordered dict of fully connected weights and biases such that
      params['weight_0'] stores the kernel of the first fully-connected layer,
      etc.
    moments: not used.
    n_hidden_units: tuple, Number of hidden units for each layer. If empty, it
      is the identity mapping.
    use_batchnorm: bool, Whether to use batchnorm after layers, except last.
    reuse: Whether to reuse the network's weights.
    scope: An optional scope for the tf operations.
    use_bounded_activation: Whether to enable bounded activation. This is useful
      for post-training quantization.
    backprop_through_moments: Whether to allow gradients to flow through the
      given support set moments. Only applies to non-transductive batch norm.
    keep_spatial_dims: is there only to match the interface.  This backbone
      cannot keep spatial dimensions, so it will fail if it's True.

  Returns:
    A 2D Tensor, where each row is the embedding of an input in inputs.
A fully connected linear network.
A fully connected linear network .
def fully_connected_network(inputs,
                            is_training,
                            weight_decay,
                            params=None,
                            moments=None,
                            n_hidden_units=(64,),
                            use_batchnorm=False,
                            reuse=tf.AUTO_REUSE,
                            scope='fully_connected',
                            use_bounded_activation=False,
                            backprop_through_moments=None,
                            keep_spatial_dims=None):
  """A fully connected linear network.

  Args:
    inputs: Tensor of shape [None, num_features], where `num_features` is the
      number of input features.
    is_training: whether it's train or test mode (for batch norm).
    weight_decay: float, scaling constant for L2 weight decay on weight
      variables.
    params: None will create new params (or reuse from scope), otherwise an
      ordered dict of fully connected weights and biases such that
      params['weight_0'] stores the kernel of the first fully-connected layer,
      etc.
    moments: not used.
    n_hidden_units: tuple, Number of hidden units for each layer. If empty, it
      is the identity mapping.
    use_batchnorm: bool, Whether to use batchnorm after layers, except last.
    reuse: Whether to reuse the network's weights.
    scope: An optional scope for the tf operations.
    use_bounded_activation: Whether to enable bounded activation. This is useful
      for post-training quantization.
    backprop_through_moments: Whether to allow gradients to flow through the
      given support set moments. Only applies to non-transductive batch norm.
    keep_spatial_dims: is there only to match the interface.  This backbone
      cannot keep spatial dimensions, so it will fail if it's True.

  Returns:
    A 2D Tensor, where each row is the embedding of an input in inputs.
  """
  assert not keep_spatial_dims
  layer = inputs
  model_params_keys, model_params_vars = [], []
  moments_keys, moments_vars = [], []
  activation_fn = functools.partial(
      relu, use_bounded_activation=use_bounded_activation)
  with tf.variable_scope(scope, reuse=reuse):
    for i, n_unit in enumerate(n_hidden_units):
      with tf.variable_scope('layer_%d' % i, reuse=reuse):
        layer, dense_params = dense(
            layer,
            n_unit,
            weight_decay,
            activation_fn=activation_fn,
            params=params)
        model_params_keys.extend(dense_params.keys())
        model_params_vars.extend(dense_params.values())
        if use_batchnorm:
          layer, bn_params, bn_moments = bn(
              layer,
              params=params,
              moments=moments,
              is_training=is_training,
              backprop_through_moments=backprop_through_moments)
          model_params_keys.extend(bn_params.keys())
          model_params_keys.extend(bn_params.values())
          moments_keys.extend(bn_moments.keys())
          moments_vars.extend(bn_moments.values())

  model_params = collections.OrderedDict(
      zip(model_params_keys, model_params_vars))
  moments = collections.OrderedDict(zip(moments_keys, moments_vars))
  return_dict = {
      'embeddings': layer,
      'params': model_params,
      'moments': moments
  }
  return return_dict
def fully_connected_network ( inputs , is_training , weight_decay , params = None , moments = None , n_hidden_units = ( 64 , ) , use_batchnorm = False , reuse = tf . AUTO_REUSE , scope = 'fully_connected' , use_bounded_activation = False , backprop_through_moments = None , keep_spatial_dims = None ) : assert not keep_spatial_dims layer = inputs model_params_keys , model_params_vars = [ ] , [ ] moments_keys , moments_vars = [ ] , [ ] activation_fn = functools . partial ( relu , use_bounded_activation = use_bounded_activation ) with tf . variable_scope ( scope , reuse = reuse ) : for i , n_unit in enumerate ( n_hidden_units ) : with tf . variable_scope ( 'layer_%d' % i , reuse = reuse ) : layer , dense_params = dense ( layer , n_unit , weight_decay , activation_fn = activation_fn , params = params ) model_params_keys . extend ( dense_params . keys ( ) ) model_params_vars . extend ( dense_params . values ( ) ) if use_batchnorm : layer , bn_params , bn_moments = bn ( layer , params = params , moments = moments , is_training = is_training , backprop_through_moments = backprop_through_moments ) model_params_keys . extend ( bn_params . keys ( ) ) model_params_keys . extend ( bn_params . values ( ) ) moments_keys . extend ( bn_moments . keys ( ) ) moments_vars . extend ( bn_moments . values ( ) ) model_params = collections . OrderedDict ( zip ( model_params_keys , model_params_vars ) ) moments = collections . OrderedDict ( zip ( moments_keys , moments_vars ) ) return_dict = { 'embeddings' : layer , 'params' : model_params , 'moments' : moments } return return_dict