-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
User defined model does not work #597
Comments
See bullet three at http://www.juliadiff.org/ForwardDiff.jl/latest/user/limitations.html. |
Thanks for the suggestion. I could make ForwardDiff work. But Flux.jacobian still does not work The changes are:
and added The error now becomes:
|
The reason that conversion method isn't defined is that it drops gradient information (otherwise we'd just use Float64 everywhere). If you want this to work you'll have to make the |
To construct the polynomials in such a way that Flux can deal with them, try function PolyModel(in::Integer, out::Integer, order::Integer)
@polyvar x[1:in]
mx0 = monomials(x, 0:order)
mx1 = hcat([exponents(m) for m in mx0]...)
return PolyModel(mx1, param(randn(out, length(mx0))))
end
function (a::PolyModel)(z)
zp = z.^a.mexp
zpprod = zp[1, :] # doing prod(zp, dims=1) would be nicer but doesn't work with Flux
for i = 2:size(zp, 1)
zpprod = zpprod .* zp[i, :]
end
return a.W*zpprod
end This works with both Flux and ForwardDiff. |
Glad to see someone else has a use for |
I have defined a model that is a multivariate polynomial. For some reason Flux.jacobian returns zero no matter what. ForwardDiff does not work either.
ForwardDiff gives:
ERROR: LoadError: TypeError: in typeassert, expected Float64, got ForwardDiff.Dual{Nothing,Float64,4}
I believe something is not being tracked, but I have no clue what.
I have posted the issue with a slightly different code here: https://discourse.julialang.org/t/flux-user-defined-layer-problem/20455?u=fastwave
The code is
The text was updated successfully, but these errors were encountered: