miguelvr
(Miguel Varela Ramos)
December 5, 2017, 11:48am
1
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
albanD
(Alban D)
December 5, 2017, 11:52am
2
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
miguelvr
(Miguel Varela Ramos)
December 5, 2017, 11:54am
3
Will this create any sort of problem in the remaining part of the model?
albanD
(Alban D)
December 5, 2017, 11:56am
4
It won’t as the original out
is not modified, just the temporary Variable
which is the result of out != out
.
1 Like