Remove @test_util.run_deprecated_v1 in sparse_tensor_test.py

PiperOrigin-RevId: 324159678
Change-Id: Ica9c8b2c05894c997695d129f723c0b76a60ec97
This commit is contained in:
Kibeom Kim 2020-07-30 23:37:30 -07:00 committed by TensorFlower Gardener
parent 8472254a23
commit 2d21b21a91

View File

@ -53,15 +53,14 @@ class SparseTensorTest(test_util.TensorFlowTestCase):
self.assertEqual(sp.dense_shape.dtype, dtypes.int64)
self.assertEqual(sp.get_shape(), (4, 5))
with self.cached_session() as sess:
value = self.evaluate(sp)
self.assertAllEqual(indices, value.indices)
self.assertAllEqual(values, value.values)
self.assertAllEqual(shape, value.dense_shape)
sess_run_value = self.evaluate(sp)
self.assertAllEqual(sess_run_value.indices, value.indices)
self.assertAllEqual(sess_run_value.values, value.values)
self.assertAllEqual(sess_run_value.dense_shape, value.dense_shape)
value = self.evaluate(sp)
self.assertAllEqual(indices, value.indices)
self.assertAllEqual(values, value.values)
self.assertAllEqual(shape, value.dense_shape)
sp_value = self.evaluate(sp)
self.assertAllEqual(sp_value.indices, value.indices)
self.assertAllEqual(sp_value.values, value.values)
self.assertAllEqual(sp_value.dense_shape, value.dense_shape)
def testShape(self):
@ -114,29 +113,27 @@ class SparseTensorTest(test_util.TensorFlowTestCase):
class ConvertToTensorOrSparseTensorTest(test_util.TensorFlowTestCase):
def test_convert_dense(self):
with self.cached_session():
value = [42, 43]
from_value = sparse_tensor.convert_to_tensor_or_sparse_tensor(
value)
self.assertAllEqual(value, self.evaluate(from_value))
value = [42, 43]
from_value = sparse_tensor.convert_to_tensor_or_sparse_tensor(
value)
self.assertAllEqual(value, self.evaluate(from_value))
@test_util.run_deprecated_v1
def test_convert_sparse(self):
with self.cached_session():
indices = [[0, 1], [1, 0]]
values = [42, 43]
shape = [2, 2]
sparse_tensor_value = sparse_tensor.SparseTensorValue(
indices, values, shape)
st = sparse_tensor.SparseTensor.from_value(sparse_tensor_value)
from_value = sparse_tensor.convert_to_tensor_or_sparse_tensor(
sparse_tensor_value).eval()
from_tensor = sparse_tensor.convert_to_tensor_or_sparse_tensor(st).eval()
for convertee in [from_value, from_tensor]:
self.assertAllEqual(sparse_tensor_value.indices, convertee.indices)
self.assertAllEqual(sparse_tensor_value.values, convertee.values)
self.assertAllEqual(
sparse_tensor_value.dense_shape, convertee.dense_shape)
indices = [[0, 1], [1, 0]]
values = [42, 43]
shape = [2, 2]
sparse_tensor_value = sparse_tensor.SparseTensorValue(
indices, values, shape)
st = sparse_tensor.SparseTensor.from_value(sparse_tensor_value)
from_value = self.evaluate(
sparse_tensor.convert_to_tensor_or_sparse_tensor(sparse_tensor_value))
from_tensor = self.evaluate(
sparse_tensor.convert_to_tensor_or_sparse_tensor(st))
for convertee in [from_value, from_tensor]:
self.assertAllEqual(sparse_tensor_value.indices, convertee.indices)
self.assertAllEqual(sparse_tensor_value.values, convertee.values)
self.assertAllEqual(
sparse_tensor_value.dense_shape, convertee.dense_shape)
class SparseTensorShapeTest(test_util.TensorFlowTestCase):