class_docstr: Tests correctness of the Y = g(X) = tanh(X) transformation.
class_docstr_tok: ["Tests","correctness","of","the","Y","=","g","(","X",")","=","tanh","(","X",")","transformation","."]
code: def testMatchWithAffineTransform(self):
      direct_bj = tanh.Tanh()
      indirect_bj = chain.Chain(
          [
              shift.Shift(tf.cast(-1.0, dtype=tf.float64)),
              scale.Scale(tf.cast(2.0, dtype=tf.float64)),
              sigmoid.Sigmoid(),
              scale.Scale(tf.cast(2.0, dtype=tf.float64)),
          ]
      )
  
      x = np.linspace(-3.0, 3.0, 100)
      y = np.tanh(x)
      self.assertAllClose(
          self.evaluate(direct_bj.forward(x)),
          self.evaluate(indirect_bj.forward(x)),
      )
      self.assertAllClose(
          self.evaluate(direct_bj.inverse(y)),
          self.evaluate(indirect_bj.inverse(y)),
      )
      self.assertAllClose(
          self.evaluate(
              direct_bj.inverse_log_det_jacobian(y, event_ndims=0)
          ),
          self.evaluate(
              indirect_bj.inverse_log_det_jacobian(y, event_ndims=0)
          ),
      )
      self.assertAllClose(
          self.evaluate(
              direct_bj.forward_log_det_jacobian(x, event_ndims=0)
          ),
          self.evaluate(
              indirect_bj.forward_log_det_jacobian(x, event_ndims=0)
          ),
      )
  
file_path: probability/tensorflow_probability/python/bijectors/tanh_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import shift
  from tensorflow_probability.python.bijectors import sigmoid
  from tensorflow_probability.python.bijectors import tanh
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 4 for calling the TanhBijectorTest obj's underlying member method code with example usage: obj.testMatchWithAffineTransform() without return types