Skip to content

Commit

Permalink
Merge pull request #42 from slimgroup/v17
Browse files Browse the repository at this point in the history
add julia 1.7 testing
  • Loading branch information
mloubout authored Dec 6, 2021
2 parents fc5ebc9 + e4a2c97 commit 1fd9342
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI

on: push
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
Expand All @@ -13,7 +19,7 @@ jobs:
fail-fast: false

matrix:
version: ['1.3', '1.4', '1.5', '1.6']
version: ['1.4', '1.5', '1.6', '1.7']
tests: ["basics", "layers", "networks"]
os: [ubuntu-latest]

Expand All @@ -34,6 +40,12 @@ jobs:
uses: julia-actions/julia-buildpkg@latest

- name: Run tests
id: test
continue-on-error: true
uses: julia-actions/julia-runtest@latest

- name: Retry tests once if failed
if: steps.test.outcome=='failure'
uses: julia-actions/julia-runtest@latest

- name: Run simple example
Expand All @@ -43,4 +55,4 @@ jobs:
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
file: lcov.info
2 changes: 1 addition & 1 deletion Project.toml
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.0.4"
version = "2.1.0"

This comment has been minimized.

Copy link
@mloubout

mloubout Dec 6, 2021

Author Member

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
4 changes: 2 additions & 2 deletions test/test_layers/test_conditional_layer_hint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using InvertibleNetworks, LinearAlgebra, Test, Random

# Random seed
Random.seed!(11)
Random.seed!(13)

#######################################################################################################################
# Test invertibility
Expand Down Expand Up @@ -200,4 +200,4 @@ for logdet in [true, false]
for permute in [true, false]
jacobian_test_par(nx, ny, n_channel, batchsize, logdet, permute)
end
end
end
4 changes: 2 additions & 2 deletions test/test_layers/test_coupling_layer_hint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ end
function grad_test_X(nx, ny, n_channel, n_hidden, batchsize, permute, logdet, rev)
logdet ? lossf = loss_logdet : lossf = loss
# Input image
X0 = randn(Float32, nx, ny, n_channel, batchsize)
X0 = rand(Float32, nx, ny, n_channel, batchsize)
dX = randn(Float32, nx, ny, n_channel, batchsize)
# Test for input X
HL = CouplingLayerHINT(n_channel, n_hidden; permute=permute, logdet=logdet)
Expand Down Expand Up @@ -178,4 +178,4 @@ dY_ = randn(Float32, size(dY))
logdet ? ((dX_, dθ_, _, _) = HL.adjointJacobian(dY_, Y)) : ((dX_, dθ_, _) = HL.adjointJacobian(dY_, Y))
a = dot(dY, dY_)
b = dot(dX, dX_)+dot(dθ, dθ_)
@test isapprox(a, b; rtol=1f-3)
@test isapprox(a, b; rtol=1f-3)
20 changes: 8 additions & 12 deletions test/test_networks/test_multiscale_conditional_hint_network.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ K = 2

function inv_test(nx, ny, n_in, batchsize, logdet, squeeze_type, split_scales)
print("\nMultiscale Conditional HINT invertibility test with squeeze_type=$(squeeze_type), split_scales=$(split_scales), logdet=$(logdet)\n")
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; squeezer = squeeze_type, logdet=logdet, split_scales=split_scales)
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; squeezer = squeeze_type(), logdet=logdet, split_scales=split_scales)

# Input image and data
X = randn(Float32, nx, ny, n_in, batchsize)
Expand Down Expand Up @@ -61,8 +61,8 @@ function loss(CH, X, Y)
end

function grad_test_X(nx, ny, n_channel, batchsize, logdet, squeeze_type, split_scales)
print("\nMultiscale Conditional HINT invertibility test with squeeze_type=$(squeeze_type), split_scales=$(split_scales), logdet=$(logdet)\n")
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; squeezer = squeeze_type, logdet=logdet, split_scales=split_scales)
print("\nMultiscale Conditional HINT gradient test with squeeze_type=$(squeeze_type), split_scales=$(split_scales), logdet=$(logdet)\n")
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; squeezer = squeeze_type(), logdet=logdet, split_scales=split_scales)


# Input image
Expand All @@ -71,12 +71,12 @@ function grad_test_X(nx, ny, n_channel, batchsize, logdet, squeeze_type, split_s

# Input data
Y0 = randn(Float32, nx, ny, n_channel, batchsize)
dY = randn(Float32, nx, ny, n_channel, batchsize)
dY = 10*randn(Float32, nx, ny, n_channel, batchsize)

f0, gX, gY = loss(CH, X0, Y0)[1:3]

maxiter = 5
h = 0.1f0
h = 0.1f0
err1 = zeros(Float32, maxiter)
err2 = zeros(Float32, maxiter)

Expand All @@ -92,11 +92,7 @@ function grad_test_X(nx, ny, n_channel, batchsize, logdet, squeeze_type, split_s
@test isapprox(err2[end] / (err2[1]/4^(maxiter-1)), 1f0; atol=1f1)
end

shuffle_sq = ShuffleLayer()
wavelet_sq = WaveletLayer()
Haar_sq = HaarLayer()

for squeeze_i in [shuffle_sq, wavelet_sq, Haar_sq]
for squeeze_i in [ShuffleLayer, WaveletLayer, HaarLayer]
for split_scales in [true, false]
for logdet in [false, true]
inv_test(nx, ny, n_in, batchsize, logdet, squeeze_i, split_scales)
Expand All @@ -111,11 +107,11 @@ end
# Gradient test

# Initialization
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; split_scales=false, k1=3, k2=1, p1=1, p2=0, squeezer = shuffle_sq);
CH = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; split_scales=false, k1=3, k2=1, p1=1, p2=0, squeezer = ShuffleLayer());
CH.forward(randn(Float32, nx, ny, n_in, batchsize), randn(Float32, nx, ny, n_in, batchsize))
θ = deepcopy(get_params(CH))

CH0 = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; split_scales=false, k1=3, k2=1, p1=1, p2=0, squeezer = shuffle_sq);
CH0 = NetworkMultiScaleConditionalHINT(n_in, n_hidden, L, K; split_scales=false, k1=3, k2=1, p1=1, p2=0, squeezer = ShuffleLayer());

CH0.forward(randn(Float32, nx, ny, n_in, batchsize), randn(Float32, nx, ny, n_in, batchsize))
θ0 = deepcopy(get_params(CH0))
Expand Down
6 changes: 3 additions & 3 deletions test/test_networks/test_unrolled_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ J = 1 .+ rand(Float32, nt*nxrec*nyrec, nx*ny*nz)
L = NetworkLoop3D(n_in, n_hidden, maxiter, Ψ; type="HINT")

# Initializations
η = randn(Float32, nx, ny, nz, 1, batchsize)
s = randn(Float32, nx, ny, nz, n_in-1, batchsize)
η = 10*randn(Float32, nx, ny, nz, 1, batchsize)
s = 10*randn(Float32, nx, ny, nz, n_in-1, batchsize)

###################################################################################################

# Test invertibility
η_, s_ = L.forward(η, s, d, J)
ηInv, sInv = L.inverse(η_, s_, d, J)
@test isapprox(norm(ηInv - η)/norm(η), 0f0, atol=1e-5)
@test isapprox(norm(sInv - s)/norm(sInv), 0f0, atol=1e-5)
@test isapprox(norm(sInv - s)/norm(s), 0f0, atol=1e-5)

# Test invertibility
η_, s_ = L.forward(η, s, d, J)
Expand Down

1 comment on commit 1fd9342

@JuliaRegistrator
Copy link

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/50026

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.1.0 -m "<description of version>" 1fd93425bad9da256adb8896df646a82c27c23bf
git push origin v2.1.0

Please sign in to comment.