Skip to content

Commit 53a39ad

Browse files
committed
fix numpy reshape arguments
1 parent 8c72723 commit 53a39ad

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

tests/test_backend.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ def test_equal(self):
724724
_ = tf.identity(mi, name=_TFOUTPUT)
725725
self._run_test_case([_OUTPUT], {_INPUT: x_val1, _INPUT1: x_val2})
726726

727-
728727
def test_sequeeze_no_axis_specified(self):
729728
x_val = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float32).reshape((2, 2, 1))
730729
x = tf.placeholder(tf.float32, [2, 2, 1], name=_TFINPUT)
@@ -982,14 +981,14 @@ def test_slice1(self):
982981
self._run_test_case([_OUTPUT], {_INPUT: x_val})
983982

984983
def test_split(self):
985-
x_val = np.linspace(1.0, 5 * 30.0, 5 * 30).astype(np.float32).reshape(5, 30)
984+
x_val = np.linspace(1.0, 5 * 30.0, 5 * 30).astype(np.float32).reshape((5, 30))
986985
x0 = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
987986
x_, _, _ = tf.split(x0, [4, 15, 11], 1)
988987
_ = tf.identity(x_, name=_TFOUTPUT)
989988
self._run_test_case([_OUTPUT], {_INPUT: x_val})
990989

991990
def test_split_with_more_outputs(self):
992-
x_val = np.linspace(1.0, 5 * 30.0, 5 * 30).astype(np.float32).reshape(5, 30)
991+
x_val = np.linspace(1.0, 5 * 30.0, 5 * 30).astype(np.float32).reshape((5, 30))
993992
x0 = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
994993
_, _, _ = tf.split(x0, [4, 15, 11], 1, name="split_test")
995994
self._run_test_case(["split_test:0", "split_test:1", "split_test:2"], {_INPUT: x_val})
@@ -1418,36 +1417,36 @@ def test_addn(self):
14181417

14191418
@skip_caffe2_backend("multiple dims not supported")
14201419
def test_strided_slice1(self):
1421-
x_val = np.arange(3 * 2 * 3).astype("float32").reshape(3, 2, 3)
1420+
x_val = np.arange(3 * 2 * 3).astype("float32").reshape((3, 2, 3))
14221421
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14231422
x_ = tf.strided_slice(x, [1, 0, 0], [2, 1, 3], [1, 1, 1])
14241423
_ = tf.identity(x_, name=_TFOUTPUT)
14251424
self._run_test_case([_OUTPUT], {_INPUT: x_val})
14261425

14271426
def test_strided_slice2(self):
1428-
x_val = np.arange(3 * 2 * 3).astype("float32").reshape(3, 2, 3)
1427+
x_val = np.arange(3 * 2 * 3).astype("float32").reshape((3, 2, 3))
14291428
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14301429
x_ = tf.strided_slice(x, [1, 0, 0], [2, 2, 3], [1, 1, 1])
14311430
_ = tf.identity(x_, name=_TFOUTPUT)
14321431
self._run_test_case([_OUTPUT], {_INPUT: x_val})
14331432

14341433
def test_strided_slice3(self):
1435-
x_val = np.arange(3 * 2 * 3).astype("float32").reshape(3, 2, 3)
1434+
x_val = np.arange(3 * 2 * 3).astype("float32").reshape((3, 2, 3))
14361435
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14371436
x_ = x[1:]
14381437
_ = tf.identity(x_, name=_TFOUTPUT)
14391438
self._run_test_case([_OUTPUT], {_INPUT: x_val})
14401439

14411440
def test_strided_slice4(self):
1442-
x_val = np.arange(3 * 2 * 3).astype("float32").reshape(3, 2, 3)
1441+
x_val = np.arange(3 * 2 * 3).astype("float32").reshape((3, 2, 3))
14431442
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14441443
x_ = x[:2]
14451444
_ = tf.identity(x_, name=_TFOUTPUT)
14461445
self._run_test_case([_OUTPUT], {_INPUT: x_val})
14471446

14481447
@skip_caffe2_backend("multiple dims not supported")
14491448
def test_strided_slice5(self):
1450-
x_val = np.arange(3 * 2 * 3).astype("float32").reshape(3, 2, 3)
1449+
x_val = np.arange(3 * 2 * 3).astype("float32").reshape((3, 2, 3))
14511450
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14521451
x_ = x[:2, 0:1, 1:]
14531452
_ = tf.identity(x_, name=_TFOUTPUT)
@@ -1457,15 +1456,15 @@ def test_strided_slice5(self):
14571456
def test_strided_slice6(self):
14581457
# example from here:
14591458
# https://www.tensorflow.org/versions/r1.0/api_docs/cc/class/tensorflow/ops/strided-slice
1460-
x_val = np.arange(5 * 6).astype("float32").reshape(5, 6)
1459+
x_val = np.arange(5 * 6).astype("float32").reshape((5, 6))
14611460
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14621461
x_ = x[2, :]
14631462
_ = tf.identity(x_, name=_TFOUTPUT)
14641463
self._run_test_case([_OUTPUT], {_INPUT: x_val})
14651464

14661465
@skip_caffe2_backend("multiple dims not supported")
14671466
def test_strided_slice7(self):
1468-
x_val = np.arange(5 * 6).astype("float32").reshape(5, 6)
1467+
x_val = np.arange(5 * 6).astype("float32").reshape((5, 6))
14691468

14701469
x = tf.placeholder(tf.float32, x_val.shape, name=_TFINPUT)
14711470
x_ = tf.strided_slice(x, [0, 1], [3, 4], [1, 1], begin_mask=2)

tests/test_custom_rnncell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,11 @@ def call(self, inputs, state):
416416
input_dim = inputs.get_shape()[-1]
417417
assert input_dim is not None, "input dimension must be defined"
418418
# W = tf.get_variable(name="W", shape=[input_dim, 3 * self._num_units], dtype=tf.float32)
419-
W = np.arange(30.0, dtype=np.float32).reshape(2, 15)
419+
W = np.arange(30.0, dtype=np.float32).reshape((2, 15))
420420
# U = tf.get_variable(name='U', shape=[self._num_units, 3 * self._num_units], dtype=tf.float32)
421-
U = np.arange(75.0, dtype=np.float32).reshape(5, 15)
421+
U = np.arange(75.0, dtype=np.float32).reshape((5, 15))
422422
# b = tf.get_variable(name='b', shape=[1, 3 * self._num_units], dtype=tf.float32)
423-
b = np.arange(15.0, dtype=np.float32).reshape(1, 15)
423+
b = np.arange(15.0, dtype=np.float32).reshape((1, 15))
424424

425425
xw = tf.split(tf.matmul(inputs, W) + b, 3, 1)
426426
hu = tf.split(tf.matmul(state, U), 3, 1)

0 commit comments

Comments
 (0)