Skip to content

Commit 1fd9342

Browse files
authored
Merge pull request #42 from slimgroup/v17
add julia 1.7 testing
2 parents fc5ebc9 + e4a2c97 commit 1fd9342

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

.github/workflows/runtests.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: CI
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
410

511
jobs:
612
test:
@@ -13,7 +19,7 @@ jobs:
1319
fail-fast: false
1420

1521
matrix:
16-
version: ['1.3', '1.4', '1.5', '1.6']
22+
version: ['1.4', '1.5', '1.6', '1.7']
1723
tests: ["basics", "layers", "networks"]
1824
os: [ubuntu-latest]
1925

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

3642
- name: Run tests
43+
id: test
44+
continue-on-error: true
45+
uses: julia-actions/julia-runtest@latest
46+
47+
- name: Retry tests once if failed
48+
if: steps.test.outcome=='failure'
3749
uses: julia-actions/julia-runtest@latest
3850

3951
- name: Run simple example
@@ -43,4 +55,4 @@ jobs:
4355
- uses: julia-actions/julia-processcoverage@v1
4456
- uses: codecov/codecov-action@v1
4557
with:
46-
file: lcov.info
58+
file: lcov.info

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "InvertibleNetworks"
22
uuid = "b7115f24-5f92-4794-81e8-23b0ddb121d3"
33
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]>"]
4-
version = "2.0.4"
4+
version = "2.1.0"
55

66
[deps]
77
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

test/test_layers/test_conditional_layer_hint.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using InvertibleNetworks, LinearAlgebra, Test, Random
66

77
# Random seed
8-
Random.seed!(11)
8+
Random.seed!(13)
99

1010
#######################################################################################################################
1111
# Test invertibility
@@ -200,4 +200,4 @@ for logdet in [true, false]
200200
for permute in [true, false]
201201
jacobian_test_par(nx, ny, n_channel, batchsize, logdet, permute)
202202
end
203-
end
203+
end

test/test_layers/test_coupling_layer_hint.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
function grad_test_X(nx, ny, n_channel, n_hidden, batchsize, permute, logdet, rev)
5151
logdet ? lossf = loss_logdet : lossf = loss
5252
# Input image
53-
X0 = randn(Float32, nx, ny, n_channel, batchsize)
53+
X0 = rand(Float32, nx, ny, n_channel, batchsize)
5454
dX = randn(Float32, nx, ny, n_channel, batchsize)
5555
# Test for input X
5656
HL = CouplingLayerHINT(n_channel, n_hidden; permute=permute, logdet=logdet)
@@ -178,4 +178,4 @@ dY_ = randn(Float32, size(dY))
178178
logdet ? ((dX_, dθ_, _, _) = HL.adjointJacobian(dY_, Y)) : ((dX_, dθ_, _) = HL.adjointJacobian(dY_, Y))
179179
a = dot(dY, dY_)
180180
b = dot(dX, dX_)+dot(dθ, dθ_)
181-
@test isapprox(a, b; rtol=1f-3)
181+
@test isapprox(a, b; rtol=1f-3)

test/test_networks/test_multiscale_conditional_hint_network.jl

+8-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ K = 2
1616

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

2121
# Input image and data
2222
X = randn(Float32, nx, ny, n_in, batchsize)
@@ -61,8 +61,8 @@ function loss(CH, X, Y)
6161
end
6262

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

6767

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

7272
# Input data
7373
Y0 = randn(Float32, nx, ny, n_channel, batchsize)
74-
dY = randn(Float32, nx, ny, n_channel, batchsize)
74+
dY = 10*randn(Float32, nx, ny, n_channel, batchsize)
7575

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

7878
maxiter = 5
79-
h = 0.1f0
79+
h = 0.1f0
8080
err1 = zeros(Float32, maxiter)
8181
err2 = zeros(Float32, maxiter)
8282

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

95-
shuffle_sq = ShuffleLayer()
96-
wavelet_sq = WaveletLayer()
97-
Haar_sq = HaarLayer()
98-
99-
for squeeze_i in [shuffle_sq, wavelet_sq, Haar_sq]
95+
for squeeze_i in [ShuffleLayer, WaveletLayer, HaarLayer]
10096
for split_scales in [true, false]
10197
for logdet in [false, true]
10298
inv_test(nx, ny, n_in, batchsize, logdet, squeeze_i, split_scales)
@@ -111,11 +107,11 @@ end
111107
# Gradient test
112108

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

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

120116
CH0.forward(randn(Float32, nx, ny, n_in, batchsize), randn(Float32, nx, ny, n_in, batchsize))
121117
θ0 = deepcopy(get_params(CH0))

test/test_networks/test_unrolled_loop.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ J = 1 .+ rand(Float32, nt*nxrec*nyrec, nx*ny*nz)
2727
L = NetworkLoop3D(n_in, n_hidden, maxiter, Ψ; type="HINT")
2828

2929
# Initializations
30-
η = randn(Float32, nx, ny, nz, 1, batchsize)
31-
s = randn(Float32, nx, ny, nz, n_in-1, batchsize)
30+
η = 10*randn(Float32, nx, ny, nz, 1, batchsize)
31+
s = 10*randn(Float32, nx, ny, nz, n_in-1, batchsize)
3232

3333
###################################################################################################
3434

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

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

0 commit comments

Comments
 (0)