Tensorflow.js tf.denseBincount() Function
The tf.denseBincount() function is used to construct a tensor of the specified size and data type. The sum of numbers at an index of the given weight tensor that corresponds to the index of the index number in the input tensor would be the tensor’s values.
tf.denseBincount (x, weights, size, binaryOutput?)
- x: This is the input tensor. It can be a 1D or a 2D tensor.
- weights: It is the weights tensor which must be the same form as x, or it must be a length-0 tensor, in which case it acts as if all the weights are equal to 1.
- size: The size of the output tensor.
- binaryOutput: This is optional. It is used to specify whether the kernel should count the number of occurrences or the appearance. False is the default value.
Returns: tf.Tensor1D or tf.Tensor2D
Tensor [[0, 1, 1, 1, 2, 3, 3, 1, 1, 2, 3],]
Tensor [[0, 0, 2, 2, 16, 9, 8, 8, 0, 5],]