log_softmax

dragon.vm.tensorflow.nn.log_softmax(
  logits,
  axis=-1,
  name=None
)[source]

Apply the composite of logarithm and softmax.

The LogSoftmax function is defined as:

\[\text{LogSoftmax}(x) = \log(\frac{e^{x_{i}}}{\sum e^{x_{j}}}) \]

The argument axis could be negative:

x = tf.random.uniform((2, 3), -0.1, 0.1)
print(tf.nn.log_softmax(x, 1))
print(tf.nn.log_softmax(x, -1))  # Equivalent
Parameters:
  • logits (dragon.Tensor) – The input tensor.
  • axis (int, optional, default=1) – The axis to reduce.
  • name (str, optional) – A optional name for the operation.
Returns:

dragon.Tensor – The output tensor.