Method: TensorStream::OpStub#sum
- Defined in:
- lib/tensor_stream/generated_stub/ops.rb
#sum(input_a, axis_p = nil, axis: nil, name: nil, keepdims: false) ⇒ Object Also known as: reduce_sum
Computes the sum of elements across dimensions of a tensor. Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1. If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned.
Options:
689 690 691 692 693 694 695 696 |
# File 'lib/tensor_stream/generated_stub/ops.rb', line 689 def sum(input_a, axis_p = nil, axis: nil, name: nil, keepdims: false) check_allowed_types(axis_p, TensorStream::Ops::INTEGER_TYPES) input_a = TensorStream.convert_to_tensor(input_a) return input_a if input_a.shape.scalar? axis_p = axis_p || axis axis_p = cast_axis(input_a, axis_p) _op(:sum, input_a, axis_p, name: name, keepdims: keepdims) end |