def test(self): pack_lt = ops.pack([self.original_lt, self.original_lt], 'batch') golden_lt = core.LabeledTensor( array_ops.stack([self.original_lt.tensor, self.original_lt.tensor]), ['batch', self.a0, self.a1, self.a2, self.a3]) self.assertLabeledTensorsEqual(pack_lt, golden_lt)
def setUp(self): super(ShuffleBatchTest, self).setUp() tensors = [] for i in range(10): offset_lt = core.LabeledTensor(constant_op.constant(i), []) tensors.append(core.add(self.original_lt, offset_lt)) self.pack_lt = ops.pack(tensors, 'batch')
def test_no_enqueue_many(self): [batch_2_op] = ops.batch([self.original_lt], batch_size=2) self.assertEqual(len(batch_2_op.axes['batch']), 2) [batch_10_op] = ops.batch([batch_2_op], batch_size=10, enqueue_many=True) self.assertLabeledTensorsEqual( ops.pack(10 * [self.original_lt], 'batch'), batch_10_op)
def test_axis(self): pack_lt = ops.pack( [self.original_lt, self.original_lt], new_axis='batch', axis_position=4) golden_lt = core.LabeledTensor( array_ops.stack( [self.original_lt.tensor, self.original_lt.tensor], axis=4), [self.a0, self.a1, self.a2, self.a3, 'batch']) self.assertLabeledTensorsEqual(pack_lt, golden_lt)
def test_invalid_input(self): with self.assertRaises(ValueError): ops.pack([self.original_lt, self.original_lt], 'channel')
def test_name(self): pack_lt = ops.pack([self.original_lt, self.original_lt], 'batch') self.assertIn('lt_pack', pack_lt.name)