We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
medium
framework
Masked Fill
Replace elements in a tensor where a boolean mask is True with a given fill value.
Input:
-
x: A tensor of any shape -
mask: A boolean tensor of the same shape (1.0 = True, 0.0 = False) -
fill_value: The value to fill where mask is True
Output: A tensor of the same shape with masked positions replaced by fill_value.
API Reference:
-
PyTorch:
x.masked_fill(mask, fill_value)ortorch.where(mask, fill_value, x) -
JAX:
jnp.where(mask, fill_value, x)
Hints
masking
torch.where
jnp.where
masked_fill
Sign in to attempt this problem and view the solution.