any

tch_any(x, dim = NULL, keepdim = FALSE, na.rm = FALSE)

Arguments

x

tensor object

dim

if NULL (the default) will reduce to a scalar. Otherwise it will return TRUE if all elements in each row of the tensor in the given dimension dim are TRUE, FALSE otherwise.

keepdim

If keepdim is TRUE, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed squeeze(), resulting in the output tensor having 1 fewer dimension than input.

na.rm

won't be used by the function. Only there to be compatible with all generic.

Examples

x <- tensor(array(c(TRUE, FALSE, TRUE, TRUE), dim = c(2, 2))) tch_any(x)
#> tensor #> 1 #> [ Variable[CPUByteType]{} ]
tch_any(x, dim = 0)
#> tensor #> 1 #> 1 #> [ Variable[CPUByteType]{2} ]
tch_any(x, dim = 1, keepdim = FALSE)
#> tensor #> 1 #> 1 #> [ Variable[CPUByteType]{2} ]