Removing NaNs not working in 0.3.0 anymore

Hi guys,

In version 0.2.0_post3 I used to do the following operation to remove NaNs that were being produced by a division by zero:

out[out != out] = 0

and it used to work!

With version 0.3.0_post4 I’m getting the following error message:

assert not ctx.needs_input_grad[1], "MaskedFill can't differentiate the mask"
AssertionError: MaskedFill can't differentiate the mask

Any tips / workarounds?

Cheers,
Miguel

Hey, the following should work.
The problem is that the result of out != out has requires_grad=True while the indexing operation cannot differentiate wrt the mask.

out[(out != out).detach()] = 0
1 Like

Will this create any sort of problem in the remaining part of the model?

It won’t as the original out is not modified, just the temporary Variable which is the result of out != out.

1 Like