-
Notifications
You must be signed in to change notification settings - Fork 15
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
ChainRulesTestUtils crashes with a custom regularization function on a Flux Dense layer #266
Comments
Odds are as a work around you need to either implement
for your type. I would need to see the stack trace to know which. Either this Probably the extra smartness needed is to know that for objects that have no fields (like nonclosure/functor functions), they are |
Here's the stacktrace for
and here's the stacktrace for
|
So the problem with the second one is just that it isn't inferrable. So ChainRulesTestUtils is working correctly there. |
For the first case what is happening seems to to be that finite differencing is returning a result that contans a Something is going wrong here: ChainRulesTestUtils.jl/src/finite_difference_calls.jl Lines 43 to 58 in 6925da1
But I have no idea what.
julia> nn = Dense(randn(1,2), randn(1), tanh)
Dense(2 => 1, tanh) # 3 parameters
julia> FiniteDifferences.to_vec(nn)
([0.6512775053740293, 0.09461593565834911, 2.580817436122576], FiniteDifferences.var"#structtype_from_vec#29"{Dense{typeof(tanh), Matrix{Float64}, Vector{Float64}}, FiniteDifferences.var"#Tuple_from_vec#52"{Tuple{Int64, Int64, Int64}, Tuple{Int64, Int64, Int64}, Tuple{typeof(identity), typeof(identity), typeof(identity)}}, Tuple{FiniteDifferences.var"#Array_from_vec#34"{Matrix{Float64}, typeof(identity)}, typeof(identity), FiniteDifferences.var"#24#27"{typeof(tanh)}}}(FiniteDifferences.var"#Tuple_from_vec#52"{Tuple{Int64, Int64, Int64}, Tuple{Int64, Int64, Int64}, Tuple{typeof(identity), typeof(identity), typeof(identity)}}((2, 3, 3), (2, 1, 0), (identity, identity, identity)), (FiniteDifferences.var"#Array_from_vec#34"{Matrix{Float64}, typeof(identity)}([0.6512775053740293 0.09461593565834911], identity), identity, FiniteDifferences.var"#24#27"{typeof(tanh)}(tanh)))) |
I have been trying to write a custom reverse rule to a simple regularization function on a Flux Dense layer, and evaluate it with ChainRulesTestUtils. The function gradient from Zygote seems to work fine with the rules, but ChainRulesTestUtils crashes. The following code is executed just fine until the test_rrule calls. The first test_rrule tries to check whether the one-layer regularization function works, but instead it raises an error
The second test_rrule crashes with
Any idea what could be the issue here? A bug somewhere?
The text was updated successfully, but these errors were encountered: