コード例 #1
0
 def test_sparse_row_envelope_empty_3d(self):
   expected_sparse_row_envelope = [1, 0, 3, 0, 0]
   with self.test_session() as sess:
     sparse_input = sparse_tensor.SparseTensor(
         indices=[[0, 0, 0], [0, 2, 0], [0, 2, 1], [0, 2, 2]],
         values=[0, 1, 2, 3],
         dense_shape=[1, 5, 3])
     sparse_row_envelope = sess.run(
         sparse_ops.sparse_row_envelope(sparse_input, 1, 2))
     self.assertAllEqual(expected_sparse_row_envelope,
                         sparse_row_envelope)
コード例 #2
0
 def test_sparse_row_envelope_unsorted_indices(self):
     expected_sparse_row_envelope = [1, 0, 3]
     with self.test_session() as sess:
         sparse_input = sparse_tensor.SparseTensor(indices=[[2, 0], [2, 2],
                                                            [2, 1], [0, 0]],
                                                   values=[0, 1, 2, 3],
                                                   dense_shape=[3, 3])
         sparse_row_envelope = sess.run(
             sparse_ops.sparse_row_envelope(sparse_input))
         self.assertAllEqual(expected_sparse_row_envelope,
                             sparse_row_envelope)
コード例 #3
0
 def test_sparse_row_envelope_empty_in_the_end(self):
     expected_sparse_row_envelope = [1, 0, 3, 0, 0]
     with self.cached_session() as sess:
         sparse_input = sparse_tensor.SparseTensor(indices=[[0, 0], [2, 0],
                                                            [2, 1], [2, 2]],
                                                   values=[0, 1, 2, 3],
                                                   dense_shape=[5, 3])
         sparse_row_envelope = sess.run(
             sparse_ops.sparse_row_envelope(sparse_input))
         self.assertAllEqual(expected_sparse_row_envelope,
                             sparse_row_envelope)
コード例 #4
0
 def test_sparse_row_envelope_unsorted_indices(self):
   expected_sparse_row_envelope = [1, 0, 3]
   with self.cached_session() as sess:
     sparse_input = sparse_tensor.SparseTensor(
         indices=[[2, 0], [2, 2], [2, 1], [0, 0]],
         values=[0, 1, 2, 3],
         dense_shape=[3, 3])
     sparse_row_envelope = sess.run(
         sparse_ops.sparse_row_envelope(sparse_input))
     self.assertAllEqual(expected_sparse_row_envelope,
                         sparse_row_envelope)