Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define typemin for tracked reals. #225

Open
manuelbb-upb opened this issue Apr 18, 2023 · 0 comments
Open

Define typemin for tracked reals. #225

manuelbb-upb opened this issue Apr 18, 2023 · 0 comments

Comments

@manuelbb-upb
Copy link

In NNlib.maxpool we encounter typemin to initialize the prospective maximum value.
typemin is not implemented for ReverseDiff.TrackedReal
This definition seems to work (it allows for taking derivatives):

Base.typemin(tr::Type{<:T}) where{V, D, O, T<:ReverseDiff.TrackedReal{V, D, O}} = T(typemin(V))

but I do not really know if that is sensible.

MWE for failure:

import NNlib: maxpool
import ReverseDiff as RD
x = reshape(Float32[ 1 2; 3 4 ], (2,2,1,1))
RD.gradient(_x -> only(maxpool(_x,(2,2))), x)[:,:,1,1] # == [0 0; 0 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant