def test_keep_scalar_axis(self): sum_lt = ops.reduce_sum(self.original_lt, ('channel', 'hihowareyou')) golden_lt = core.LabeledTensor( math_ops.reduce_sum( self.original_lt.tensor, 1, keep_dims=True), [self.a0, ('channel', ['hihowareyou']), self.a2, self.a3]) self.assertLabeledTensorsEqual(sum_lt, golden_lt)
def test_keep_scalar_axis(self): sum_lt = ops.reduce_sum(self.original_lt, ('channel', 'hihowareyou')) golden_lt = core.LabeledTensor( math_ops.reduce_sum( self.original_lt.tensor, 1, keepdims=True), [self.a0, ('channel', ['hihowareyou']), self.a2, self.a3]) self.assertLabeledTensorsEqual(sum_lt, golden_lt)
def test_none(self): sum_lt = ops.reduce_sum(self.original_lt) golden_lt = core.LabeledTensor( math_ops.reduce_sum(self.original_lt.tensor), []) self.assertLabeledTensorsEqual(sum_lt, golden_lt)
def test_empty_list(self): reduce_lt = ops.reduce_sum(self.original_lt, []) self.assertLabeledTensorsEqual(reduce_lt, self.original_lt)
def test_scalar(self): scalar_lt = core.LabeledTensor(constant_op.constant(42), []) reduce_lt = ops.reduce_sum(scalar_lt, []) self.assertLabeledTensorsEqual(reduce_lt, scalar_lt)
def test_drop_scalar_axis(self): sum_lt = ops.reduce_sum(self.original_lt, 'channel') golden_lt = core.LabeledTensor( math_ops.reduce_sum(self.original_lt.tensor, 1), [self.a0, self.a2, self.a3]) self.assertLabeledTensorsEqual(sum_lt, golden_lt)
def test_name(self): sum_lt = ops.reduce_sum(self.original_lt, {'channel'}) self.assertIn('lt_reduce_sum', sum_lt.name)