masked_fill¶
- nvtripy.masked_fill(input: Tensor, mask: Tensor, value: Number) Tensor [source]¶
Returns a new tensor filled with
value
wheremask
isTrue
and elements from the input tensor otherwise.- Parameters:
- Returns:
[dtype=T1] A new tensor of the same shape as the input tensor.
- Return type:
Example
1mask = tp.Tensor([[True, False], [True, True]]) 2input = tp.zeros([2, 2]) 3output = tp.masked_fill(input, mask, -1.0)
Local Variables¶>>> mask tensor( [[True, False], [True, True]], dtype=bool, loc=cpu:0, shape=(2, 2)) >>> input tensor( [[0, 0], [0, 0]], dtype=float32, loc=gpu:0, shape=(2, 2)) >>> output tensor( [[-1, 0], [-1, -1]], dtype=float32, loc=gpu:0, shape=(2, 2))