Пример #1
0
 def testNHWCtoWHCN(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN")
   with self.session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #2
0
 def testArbitraryASCII(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq")
   with self.session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #3
0
 def testArbitraryASCII(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #4
0
 def testNHWCtoNCHW(self):
   x_val = [1, -3, -2]
   y_val_expected = [2, 2, 3]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW")
   with self.session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #5
0
 def testNHWCtoNCHW(self):
   x_val = [1, -3, -2]
   y_val_expected = [2, 2, 3]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #6
0
 def testNHWCtoWHCN(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #7
0
 def testArbitraryASCII(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #8
0
 def testNHWCtoNCHW(self):
   x_val = [1, -3, -2]
   y_val_expected = [2, 2, 3]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #9
0
 def testNHWCtoWHCN(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN")
   with test_util.use_gpu():
     y_val = self.evaluate(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #10
0
 def testArbitraryASCII(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq")
   with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #11
0
 def testNHWCtoWHCN(self):
   x_val = [-4, -3, -2, -1, 0, 1, 2, 3]
   y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN")
   with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #12
0
 def testNHWCtoNCHW(self):
   x_val = [1, -3, -2]
   y_val_expected = [2, 2, 3]
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW")
   with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #13
0
 def _test(self, input_data, src_format, dst_format, expected):
   for dtype in {np.int32, np.int64}:
     x = np.array(input_data, dtype=dtype)
     with self.session() as session:
       with self.test_scope():
         placeholder = array_ops.placeholder(dtypes.as_dtype(x.dtype), x.shape)
         param = {placeholder: x}
         output = nn_ops.data_format_dim_map(
             placeholder, src_format=src_format, dst_format=dst_format)
       result = session.run(output, param)
     self.assertAllEqual(result, expected)
Пример #14
0
 def _test(self, x_val, y_val_expected):
   x = constant_op.constant(x_val)
   y = nn_ops.data_format_dim_map(x)
   with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess:
     y_val = sess.run(y)
     self.assertAllEqual(y_val, y_val_expected)
Пример #15
0
  def _test(self, x_val, y_val_expected):
    x = constant_op.constant(x_val)
    y = nn_ops.data_format_dim_map(x)

    y_val = self.evaluate(y)
    self.assertAllEqual(y_val, y_val_expected)
Пример #16
0
  def _test(self, x_val, y_val_expected):
    x = constant_op.constant(x_val)
    y = nn_ops.data_format_dim_map(x)

    y_val = self.evaluate(y)
    self.assertAllEqual(y_val, y_val_expected)