(hidden, labels, n_class, initializer, scope, reuse=None,
                        return_logits=False)
Different classification tasks should use different scope names to ensure
      different dense layers (parameters) are used to produce the logits.

      An exception will be in transfer learning, where one hopes to transfer
      the classification weights.
Different classification tasks should use different scope names to ensure
      different dense layers (parameters) are used to produce the logits.
Different classification tasks should use different scope names to ensure different dense layers ( parameters ) are used to produce the logits .
def classification_loss(hidden, labels, n_class, initializer, scope, reuse=None,
                        return_logits=False):
  """
      Different classification tasks should use different scope names to ensure
      different dense layers (parameters) are used to produce the logits.

      An exception will be in transfer learning, where one hopes to transfer
      the classification weights.
  """

  with tf.variable_scope(scope, reuse=reuse):
    logits = tf.layers.dense(
        hidden,
        n_class,
        kernel_initializer=initializer,
        name='logit')

    one_hot_target = tf.one_hot(labels, n_class, dtype=hidden.dtype)
    loss = -tf.reduce_sum(tf.nn.log_softmax(logits) * one_hot_target, -1)

    if return_logits:
      return loss, logits

    return loss
def classification_loss ( hidden , labels , n_class , initializer , scope , reuse = None , return_logits = False ) : with tf . variable_scope ( scope , reuse = reuse ) : logits = tf . layers . dense ( hidden , n_class , kernel_initializer = initializer , name = 'logit' ) one_hot_target = tf . one_hot ( labels , n_class , dtype = hidden . dtype ) loss = - tf . reduce_sum ( tf . nn . log_softmax ( logits ) * one_hot_target , - 1 ) if return_logits : return loss , logits return loss