class_docstr: Tests correctness of the Y = g(X) = exp(X) / sum(exp(X)) transformation.
class_docstr_tok: ["Tests","correctness","of","the","Y","=","g","(","X",")","=","exp","(","X",")","\/","sum","(","exp","(","X",")",")","transformation","."]
code: def testBijectorUnknownShape(self):
      softmax = softmax_centered.SoftmaxCentered()
      self.assertStartsWith(softmax.name, "softmax_centered")
      x_ = np.log([[2.0, 3, 4], [4.0, 8, 12]]).astype(np.float32)
      y_ = np.array(
          [[0.2, 0.3, 0.4, 0.1], [0.16, 0.32, 0.48, 0.04]],
          dtype=np.float32,
      )
      x = tf1.placeholder_with_default(x_, shape=[2, None])
      y = tf1.placeholder_with_default(y_, shape=[2, None])
      self.assertAllClose(y_, self.evaluate(softmax.forward(x)))
      self.assertAllClose(x_, self.evaluate(softmax.inverse(y)))
      self.assertAllClose(
          -np.sum(np.log(y_), axis=1)
          - 0.5 * np.log(4.0)[np.newaxis, ...],
          self.evaluate(
              softmax.inverse_log_det_jacobian(y, event_ndims=1)
          ),
          atol=0.0,
          rtol=1e-7,
      )
      self.assertAllClose(
          -self.evaluate(
              softmax.inverse_log_det_jacobian(y, event_ndims=1)
          ),
          self.evaluate(
              softmax.forward_log_det_jacobian(x, event_ndims=1)
          ),
          atol=0.0,
          rtol=1e-7,
      )
  
file_path: probability/tensorflow_probability/python/bijectors/softmax_centered_test.py
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import softmax_centered
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 2 for calling the SoftmaxCenteredBijectorTest obj's underlying member method code with example usage: obj.testBijectorUnknownShape() without return types