masked_fill_¶
- paddle. masked_fill_ ( x, mask, value, name=None ) [source]
-
Inplace version of
masked_fill
API, the output Tensor will be inplaced with inputx
. Please refer to masked_fill.Examples
>>> >>> import paddle >>> x = paddle.ones((3, 3), dtype="float32") >>> mask = paddle.to_tensor([[True, False, False]]) >>> out = paddle.masked_fill_(x, mask, 2) >>> print(out) Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True, [[2., 1., 1.], [2., 1., 1.], [2., 1., 1.]])