Fill the positions where mask holds with source's leading elements.
input and mask broadcast together; the k-th position the
mask selects, in row-major order, takes source.reshape(-1)[k], and
every other position keeps input's value. Differentiable through
input (where the mask is False) and source (its elements that
were written).
Parameters
Returns
TensorA new tensor of the broadcast shape of input and mask, in
input's dtype — never input itself, even when the mask
selects nothing.
Raises
lucid._C.engine.DtypeMismatchmask is not bool, or source's dtype is not input's.lucid._C.engine.ShapeMismatchsource has fewer elements than the mask selects.IndexErrorinput and mask do not broadcast together.Examples
>>> import lucid
>>> mask = lucid.tensor([True, False])
>>> lucid.masked_scatter(lucid.zeros(2, 2), mask, lucid.tensor([1.0, 2.0, 3.0]))
tensor([[1., 0.], [2., 0.]])