Count the frequency of each value in an array of non-negative ints.

tch_bincount(x, weights = NULL, minlength = 0)

Arguments

x

tensor object

weights

optional, weight for each value in the input tensor. Should be of same size as input tensor.

minlength

optional, minimum number of bins. Should be non-negative.

Examples

x <- tensor(sample(0:9, 50, replace = TRUE)) tch_bincount(x)
#> tensor #> 5 #> 2 #> 4 #> 4 #> 3 #> 7 #> 9 #> 6 #> 4 #> 6 #> [ Variable[CPULongType]{10} ]