filtering for isnan can result in NaN gradient
Open
- Dominant language
- Julia
- Stars
- 54
- Forks
- 37
- Avg merge
- 5h 49m
- Merged PRs (30d)
- 1
Description
This works as expected
```
function test(x)
y = [1.0, NaN, 1.0]
sum(filter(!isnan, x.-y))
end
julia> Tracker.gradient(test, [1, 2, 3])
([1.0, 0.0, 1.0] (tracked),)
```
This does not
```
function test2(x)
y = [1.0, NaN, 2.0]
sum(filter(!isnan, (x.-y).^2))
end
julia> Tracker.gradient(test2, [1,2,3])
([0.0, NaN, 2.0] (tracked),)
```
I wouldn't expect the computation (x[2]-y[2])^2 to be in the graph for the result, so I don't understand why this would return NaN. Have I missed something?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.