aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops/sparse_ops_test.py
diff options
context:
space:
mode:
authorGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-25 08:48:47 -0800
committerGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-25 08:48:47 -0800
commit854f49bd43588c062b046384f239f64a3d819702 (patch)
treec2373bf71ef65ae4c116ea703947141281c1eace /tensorflow/python/ops/sparse_ops_test.py
parent9c3043ff3bf31a6a81810b4ce9e87ef936f1f529 (diff)
TensorFlow: Upstream changes to git
Changes: - Updates to docs - Several changes for Python 3 compatibility - Added license headers Base CL: 108710566
Diffstat (limited to 'tensorflow/python/ops/sparse_ops_test.py')
-rw-r--r--tensorflow/python/ops/sparse_ops_test.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/tensorflow/python/ops/sparse_ops_test.py b/tensorflow/python/ops/sparse_ops_test.py
index 046625eefa..c6e91dcd71 100644
--- a/tensorflow/python/ops/sparse_ops_test.py
+++ b/tensorflow/python/ops/sparse_ops_test.py
@@ -23,9 +23,9 @@ import tensorflow.python.platform
import numpy as np
+from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_util
-from tensorflow.python.framework import types
from tensorflow.python.ops import constant_op
from tensorflow.python.ops import sparse_ops
from tensorflow.python.platform import googletest
@@ -41,9 +41,9 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase):
val = np.array([0, 10, 13, 14, 32, 33])
shape = np.array([5, 6])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
+ constant_op.constant(ind, dtypes.int64),
constant_op.constant(val, dtype),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(shape, dtypes.int64))
def _SparseTensor_2x3x4(self, dtype):
ind = np.array([
@@ -55,13 +55,13 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase):
val = np.array([1, 10, 12, 103, 111, 113, 122])
shape = np.array([2, 3, 4])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
+ constant_op.constant(ind, dtypes.int64),
constant_op.constant(val, dtype),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(shape, dtypes.int64))
def testInt32(self):
with self.test_session(use_gpu=False):
- sp_input = self._SparseTensor_5x6(types.int32)
+ sp_input = self._SparseTensor_5x6(dtypes.int32)
output = sparse_ops.sparse_to_indicator(sp_input, 50).eval()
expected_output = np.zeros((5, 50), dtype=np.bool)
@@ -73,7 +73,7 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase):
def testInt64(self):
with self.test_session(use_gpu=False):
- sp_input = self._SparseTensor_5x6(types.int64)
+ sp_input = self._SparseTensor_5x6(dtypes.int64)
output = sparse_ops.sparse_to_indicator(sp_input, 50).eval()
expected_output = np.zeros((5, 50), dtype=np.bool)
@@ -85,7 +85,7 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase):
def testHigherRank(self):
with self.test_session(use_gpu=False):
- sp_input = self._SparseTensor_2x3x4(types.int64)
+ sp_input = self._SparseTensor_2x3x4(dtypes.int64)
output = sparse_ops.sparse_to_indicator(sp_input, 200).eval()
expected_output = np.zeros((2, 3, 200), dtype=np.bool)
@@ -107,9 +107,9 @@ class SparseRetainTest(test_util.TensorFlowTestCase):
val = np.array([0, 10, 13, 14, 32, 33])
shape = np.array([5, 6])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
- constant_op.constant(val, types.int32),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(ind, dtypes.int64),
+ constant_op.constant(val, dtypes.int32),
+ constant_op.constant(shape, dtypes.int64))
def testBasic(self):
with self.test_session(use_gpu=False) as sess:
@@ -153,9 +153,9 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase):
val = np.array([0, 10, 13, 14, 32, 33])
shape = np.array([5, 6])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
- constant_op.constant(val, types.int32),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(ind, dtypes.int64),
+ constant_op.constant(val, dtypes.int32),
+ constant_op.constant(shape, dtypes.int64))
def _SparseTensor_String5x6(self):
ind = np.array([
@@ -165,18 +165,18 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase):
val = np.array(["a", "b", "c", "d", "e", "f"])
shape = np.array([5, 6])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
- constant_op.constant(val, types.string),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(ind, dtypes.int64),
+ constant_op.constant(val, dtypes.string),
+ constant_op.constant(shape, dtypes.int64))
def _SparseTensor_2x6(self):
ind = np.array([[0, 0], [1, 0], [1, 3], [1, 4]])
val = np.array([0, 10, 13, 14])
shape = np.array([2, 6])
return ops.SparseTensor(
- constant_op.constant(ind, types.int64),
- constant_op.constant(val, types.int32),
- constant_op.constant(shape, types.int64))
+ constant_op.constant(ind, dtypes.int64),
+ constant_op.constant(val, dtypes.int32),
+ constant_op.constant(shape, dtypes.int64))
def testFillNumber(self):
with self.test_session(use_gpu=False) as sess:
@@ -207,7 +207,8 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase):
self.assertAllEqual(
output.indices,
[[0, 0], [1, 0], [1, 3], [1, 4], [2, 0], [3, 2], [3, 3], [4, 0]])
- self.assertAllEqual(output.values, ["a", "b", "c", "d", "", "e", "f", ""])
+ self.assertAllEqual(output.values,
+ [b"a", b"b", b"c", b"d", b"", b"e", b"f", b""])
self.assertAllEqual(output.shape, [5, 6])
self.assertAllEqual(empty_row_indicator_out,
np.array([0, 0, 1, 0, 1]).astype(np.bool))