edsnlp.utils.torch
mask_to_triangle
Convert a boolean mask to a tensor containing distance to the nearest edge of the mask, in each direction. For example, if the mask is
[
[1, 1, 1, 1, 1],
[1, 1, 1, 0, 0],
]
The output will be
[
[0, 1, 2, 1, 0],
[0, 1, 0, -1, -2]
]
Parameters
PARAMETER | DESCRIPTION |
---|---|
mask | A boolean mask
|
RETURNS | DESCRIPTION |
---|---|
Tensor | |