
Last chance! 50% off unlimited learning
Sale ends in
Masked_select
torch_masked_select(self, mask)
(Tensor) the input tensor.
(BoolTensor) the tensor containing the binary mask to index with
Returns a new 1-D tensor which indexes the input
tensor according to
the boolean mask mask
which is a BoolTensor
.
The shapes of the mask
tensor and the input
tensor don't need
to match, but they must be broadcastable .
# NOT RUN {
if (torch_is_installed()) {
x = torch_randn(c(3, 4))
x
mask = x$ge(0.5)
mask
torch_masked_select(x, mask)
}
# }
Run the code above in your browser using DataLab