We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
using Lux, CUDA, cuDNN, Random, OneHotArrays, Zygote using Functors, Optimisers, Printf model = Chain( Conv((5, 5), 1 => 6, relu), MaxPool((2, 2)), Conv((5, 5), 6 => 16, relu), MaxPool((2, 2)), FlattenLayer(3), Chain( Dense(256 => 128, relu), Dense(128 => 84, relu), Dense(84 => 2) ) ) dev = gpu_device(; force=true) ps, st = Lux.setup(Random.default_rng(), model) |> dev; x = randn(Float32, 28,28,1,32) |> dev δ = randn(Float32, 28,28,1,32) |> dev y = onehotbatch(rand((1,2),32), 1:2) |> dev const celoss = CrossEntropyLoss(;logits=true) const regloss = MSELoss() function loss_function(model, ps, st, x, y) pred, _ = model(x, ps, st) return celoss(pred, y) end function ∂xloss_function(model, ps, st, x, δ, y) smodel = StatefulLuxLayer{true}(model, ps, st) ∂x = only(Zygote.gradient(Base.Fix2(celoss, y) ∘ smodel, x)) regloss(∂x, δ) + loss_function(model, ps, st, x, y) end function ∂∂xloss_function(model, ps, st, x, δ, y) only(Zygote.gradient(ps -> ∂xloss_function(model, ps, st, x, δ, y), ps)) end ∂∂xloss_function(model, ps, st, x, δ, y)
Mostly a dup of #1007, but since this is needed I will prioritize implementing this.
cc @pevnak so that you are in the loop
The text was updated successfully, but these errors were encountered:
avik-pal
Successfully merging a pull request may close this issue.
Mostly a dup of #1007, but since this is needed I will prioritize implementing this.
cc @pevnak so that you are in the loop
The text was updated successfully, but these errors were encountered: