def testMeanNan(self):
     rt_as_list = [[0, 1, 2, 3], [4], [], [5, 6], [7], [8, 9]]
     expected = (np.array([0 + 1 + 2 + 3, 4, 0, 5 + 6, 7, 8 + 9]) /
                 np.array([4, 1, 0, 2, 1, 2]))
     rt_input = ragged_factory_ops.constant(rt_as_list)
     reduced = ragged_math_ops.reduce_mean(rt_input, axis=1)
     self.assertEqualWithNan(self.evaluate(reduced), expected)
 def testMeanNan(self):
   rt_as_list = [[0, 1, 2, 3], [4], [], [5, 6], [7], [8, 9]]
   expected = (
       np.array([0 + 1 + 2 + 3, 4, 0, 5 + 6, 7, 8 + 9]) / np.array(
           [4, 1, 0, 2, 1, 2]))
   rt_input = ragged_factory_ops.constant(rt_as_list)
   reduced = ragged_math_ops.reduce_mean(rt_input, axis=1)
   self.assertEqualWithNan(self.evaluate(reduced), expected)
示例#3
0
 def testMeanWithTensorInputs(self):
   tensor = [[1.0, 2.0, 3.0], [10.0, 20.0, 30.0]]
   expected = [2.0, 20.0]
   reduced = ragged_math_ops.reduce_mean(tensor, axis=1)
   self.assertAllEqual(reduced, expected)
 def testMeanWithTensorInputs(self):
   tensor = [[1.0, 2.0, 3.0], [10.0, 20.0, 30.0]]
   expected = [2.0, 20.0]
   reduced = ragged_math_ops.reduce_mean(tensor, axis=1)
   self.assertRaggedEqual(reduced, expected)