mindspore.ops.bincount
- mindspore.ops.bincount(input, weights=None, minlength=0)[source]
- Count the frequency of each value in the input tensor of non-negative ints. - If you don't specify minlength, the length of output tensor the length of the output tensor is max( input ) + 1. - If minlength is specified, the length of the output tensor is max([max( input ) + 1, minlength]). - If 'weights' is specified, the output results are weighted. If n is the value at position i, i.e - out[n] += weight[i]instead of- out[n] += 1.- Note - If input contains negative value, the result will be undefined. - Parameters
- Returns
- Tensor, a tensor of shape [max(input)+1] if input is non-empty, otherwise, the shape is [0]. 
 - Supported Platforms:
- Ascend- GPU- CPU
 - Examples - >>> import mindspore >>> x = mindspore.tensor([2, 4, 1, 0, 0], dtype=mindspore.int64) >>> print(mindspore.ops.bincount(x, minlength=7)) [2. 1. 1. 0. 1. 0. 0.] >>> weights = mindspore.tensor([0, 0.25, 0.5, 0.75, 1], dtype=mindspore.float32) >>> print(mindspore.ops.bincount(x, weights=weights)) [1.75 0.5 0. 0. 0.25]