-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from slimgroup/flux-fix
fix Flux compat
- Loading branch information
Showing
9 changed files
with
88 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "InvertibleNetworks" | ||
uuid = "b7115f24-5f92-4794-81e8-23b0ddb121d3" | ||
authors = ["Philipp Witte <[email protected]>", "Ali Siahkoohi <[email protected]>", "Mathias Louboutin <[email protected]>", "Gabrio Rizzuti <[email protected]>", "Rafael Orozco <[email protected]>", "Felix J. herrmann <[email protected]>"] | ||
version = "2.2.4" | ||
version = "2.2.5" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
[deps] | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using InvertibleNetworks, Flux, Test, LinearAlgebra | ||
|
||
# Define network | ||
nx = 1 | ||
ny = 1 | ||
n_in = 2 | ||
n_hidden = 10 | ||
batchsize = 32 | ||
|
||
# net | ||
AN = ActNorm(n_in; logdet = false) | ||
C = CouplingLayerGlow(n_in, n_hidden; logdet = false, k1 = 1, k2 = 1, p1 = 0, p2 = 0) | ||
pan, pc = deepcopy(get_params(AN)), deepcopy(get_params(C)) | ||
model = Chain(AN, C) | ||
|
||
# dummy input & target | ||
X = randn(Float32, nx, ny, n_in, batchsize) | ||
Y = model(X) | ||
X0 = rand(Float32, nx, ny, n_in, batchsize) .+ 1 | ||
|
||
# loss fn | ||
loss(model, X, Y) = Flux.mse(Y, model(X)) | ||
|
||
# old, implicit-style Flux | ||
θ = Flux.params(model) | ||
opt = Descent(0.001) | ||
|
||
l, grads = Flux.withgradient(θ) do | ||
loss(model, X0, Y) | ||
end | ||
|
||
for θi in θ | ||
@test θi ∈ keys(grads.grads) | ||
@test !isnothing(grads.grads[θi]) | ||
@test size(grads.grads[θi]) == size(θi) | ||
end | ||
|
||
Flux.update!(opt, θ, grads) | ||
|
||
for i = 1:5 | ||
li, grads = Flux.withgradient(θ) do | ||
loss(model, X, Y) | ||
end | ||
|
||
@info "Loss: $li" | ||
@test li != l | ||
global l = li | ||
|
||
Flux.update!(opt, θ, grads) | ||
end |
1 comment
on commit df92d43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/81994
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v2.2.5 -m "<description of version>" df92d4301b2d84e6d3c7637e7d643db2952b0532
git push origin v2.2.5
@JuliaRegistrator register