Exemplo n.º 1
0
  def test_rotate_jacobian_preset(self):
    """Test the Jacobian of the rotate function."""
    x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle()
    x_point_init = np.random.uniform(size=x_axis_init.shape)

    self.assert_jacobian_is_correct_fn(
        axis_angle.rotate, [x_point_init, x_axis_init, x_angle_init])
Exemplo n.º 2
0
    def test_from_axis_angle_jacobian_preset(self):
        """Test the Jacobian of the from_axis_angle function."""
        x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle(
        )

        self.assert_jacobian_is_finite_fn(euler.from_axis_angle,
                                          [x_axis_init, x_angle_init])
Exemplo n.º 3
0
    def test_inverse_jacobian_preset(self):
        """Test the Jacobian of the inverse function."""
        x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle(
        )

        self.assert_jacobian_is_correct_fn(
            lambda x: axis_angle.inverse(x, x_angle_init)[0], [x_axis_init])
        self.assert_jacobian_is_correct_fn(
            lambda x: axis_angle.inverse(x_axis_init, x)[1], [x_angle_init])
Exemplo n.º 4
0
  def test_axis_angle_jacobian_preset(self):
    """Test the Jacobian of the from_axis_angle function."""
    x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle()
    x_axis = tf.convert_to_tensor(value=x_axis_init)
    x_angle = tf.convert_to_tensor(value=x_angle_init)

    y = quaternion.from_axis_angle(x_axis, x_angle)

    self.assert_jacobian_is_correct(x_axis, x_axis_init, y)
    self.assert_jacobian_is_correct(x_angle, x_angle_init, y)
Exemplo n.º 5
0
    def test_rotate_jacobian_preset(self):
        """Test the Jacobian of the rotate function."""
        x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle(
        )
        x_axis = tf.convert_to_tensor(value=x_axis_init)
        x_angle = tf.convert_to_tensor(value=x_angle_init)
        x_point_init = np.random.uniform(size=x_axis.shape)
        x_point = tf.convert_to_tensor(value=x_point_init)

        y = axis_angle.rotate(x_point, x_axis, x_angle)

        self.assert_jacobian_is_correct(x_axis, x_axis_init, y)
        self.assert_jacobian_is_correct(x_angle, x_angle_init, y)
        self.assert_jacobian_is_correct(x_point, x_point_init, y)
Exemplo n.º 6
0
  def test_inverse_jacobian_preset(self):
    """Test the Jacobian of the inverse function."""
    x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle()

    if tf.executing_eagerly():
      # Because axis is returned as is, gradient calculation fails in graph mode
      # but not in eager mode. This is a side effect of having a graph rather
      # than a problem of the function.
      with self.subTest("axis"):
        self.assert_jacobian_is_correct_fn(
            lambda x: axis_angle.inverse(x, x_angle_init)[0], [x_axis_init])

    with self.subTest("angle"):
      self.assert_jacobian_is_correct_fn(
          lambda x: axis_angle.inverse(x_axis_init, x)[1], [x_angle_init])