def testExplicitAxisOptimizations(self):
   rt = ragged.from_row_splits(b'a b c d e f g'.split(), [0, 2, 5, 6, 6, 7])
   with self.test_session():
     self.assertEqual(ragged.bounding_shape(rt, 0).eval().tolist(), 5)
     self.assertEqual(ragged.bounding_shape(rt, 1).eval().tolist(), 3)
     self.assertEqual(
         ragged.bounding_shape(rt, [1, 0]).eval().tolist(), [3, 5])
示例#2
0
 def test2DRaggedTensorWithOneRaggedDimension(self):
   values = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
   rt1 = ragged.from_row_splits(values, [0, 2, 5, 6, 6, 7])
   rt2 = ragged.from_row_splits(values, [0, 7])
   rt3 = ragged.from_row_splits(values, [0, 0, 7, 7])
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt1)).tolist(), [5, 3])
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt2)).tolist(), [1, 7])
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt3)).tolist(), [3, 7])
 def testExplicitAxisOptimizations(self):
     rt = ragged.from_row_splits(b'a b c d e f g'.split(),
                                 [0, 2, 5, 6, 6, 7])
     with self.test_session():
         self.assertEqual(ragged.bounding_shape(rt, 0).eval().tolist(), 5)
         self.assertEqual(ragged.bounding_shape(rt, 1).eval().tolist(), 3)
         self.assertEqual(
             ragged.bounding_shape(rt, [1, 0]).eval().tolist(), [3, 5])
 def test3DRaggedTensorWithOneRaggedDimension(self):
   values = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]]
   rt1 = ragged.from_row_splits(values, [0, 2, 5, 6, 6, 7])
   rt2 = ragged.from_row_splits(values, [0, 7])
   rt3 = ragged.from_row_splits(values, [0, 0, 7, 7])
   with self.test_session():
     self.assertEqual(ragged.bounding_shape(rt1).eval().tolist(), [5, 3, 2])
     self.assertEqual(ragged.bounding_shape(rt2).eval().tolist(), [1, 7, 2])
     self.assertEqual(ragged.bounding_shape(rt3).eval().tolist(), [3, 7, 2])
示例#5
0
 def test3DRaggedTensorWithOneRaggedDimension(self):
   values = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]]
   rt1 = ragged.from_row_splits(values, [0, 2, 5, 6, 6, 7])
   rt2 = ragged.from_row_splits(values, [0, 7])
   rt3 = ragged.from_row_splits(values, [0, 0, 7, 7])
   self.assertEqual(
       self.evaluate(ragged.bounding_shape(rt1)).tolist(), [5, 3, 2])
   self.assertEqual(
       self.evaluate(ragged.bounding_shape(rt2)).tolist(), [1, 7, 2])
   self.assertEqual(
       self.evaluate(ragged.bounding_shape(rt3)).tolist(), [3, 7, 2])
示例#6
0
 def testExplicitAxisOptimizations(self):
   rt = ragged.from_row_splits(b'a b c d e f g'.split(), [0, 2, 5, 6, 6, 7])
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt, 0)).tolist(), 5)
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt, 1)).tolist(), 3)
   self.assertEqual(
       self.evaluate(ragged.bounding_shape(rt, [1, 0])).tolist(), [3, 5])
示例#7
0
 def testNonRaggedTensor(self):
   dt = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
   self.assertEqual(self.evaluate(ragged.bounding_shape(dt)).tolist(), [4, 3])
示例#8
0
 def testDocStringExample(self):
   # This is the example from ragged.bounding_shape.__doc__.
   rt = ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]])
   self.assertEqual(self.evaluate(ragged.bounding_shape(rt)).tolist(), [5, 4])
 def testNonRaggedTensor(self):
   dt = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
   with self.test_session():
     self.assertEqual(ragged.bounding_shape(dt).eval().tolist(), [4, 3])
 def testNonRaggedTensor(self):
     dt = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
     with self.test_session():
         self.assertEqual(ragged.bounding_shape(dt).eval().tolist(), [4, 3])