def testRepeatMatrixAxis1(self): with self.session(): x = np.array([[1, 2], [3, 4]], dtype=np.int32) v_tf = repeat_ops.repeat(constant_op.constant(x), constant_op.constant(3), axis=1) v_np = np.repeat(x, 3, axis=1) self.assertAllEqual(self.evaluate(v_tf), v_np)
def testRepeatDTypes(self): for dtype in [ np.int8, np.int16, np.uint8, np.uint16, np.int32, np.int64 ]: with self.session(): x = np.array([[1, 2], [3, 4]], dtype=dtype) v_tf = repeat_ops.repeat(constant_op.constant(x), 2) v_np = np.repeat(x, 2) self.assertAllEqual(self.evaluate(v_tf), v_np)
def testRepeatMatrixAxis0(self): with self.session(): x = np.array([[1, 2], [3, 4]], dtype=np.int32) for axis in (0, 1): v_tf = repeat_ops.repeat(constant_op.constant(x), constant_op.constant([1, 2]), axis=axis) v_np = np.repeat(x, [1, 2], axis=axis) self.assertAllEqual(self.evaluate(v_tf), v_np)
def repeat_base(repeats): """Repeat using `tf.while_loop` with `Tensor` concatenation.""" values = tf.equal(tf.range(tf.size(repeats), dtype=tf.int32) % 2, 1) return repeat_ops.repeat(values, repeats)
def testRepeatScalar(self): with self.session(): v_tf = repeat_ops.repeat(constant_op.constant(3), 4) v_np = np.repeat(3, 4) self.assertAllEqual(self.evaluate(v_tf), v_np)