Where
torch_where(condition, self = NULL, other = NULL)
condition
: (BoolTensor) When TRUE (nonzero), yield x, otherwise yield yself
: (Tensor) values selected at indices where condition
is TRUE
other
: (Tensor) values selected at indices where condition
is FALSE
The tensors `condition`, `x`, `y` must be broadcastable .
See also torch_nonzero()
.
Return a tensor of elements selected from either x
or y
, depending on condition
.
The operation is defined as:
torch_where(condition)
is identical to torch_nonzero(condition, as_tuple=TRUE)
.
if (torch_is_installed()) { ## Not run: x = torch_randn(c(3, 2)) y = torch_ones(c(3, 2)) x torch_where(x > 0, x, y) ## End(Not run) }
Useful links