Skip to content

Commit

Permalink
Update CI workflows (#18)
Browse files Browse the repository at this point in the history
* Update CI workflows

* Use StableRNG for random seeds in tests for consistency across Julia versions. This requires updating test references.
  • Loading branch information
adrhill authored Oct 10, 2024
1 parent 6679139 commit 22051fd
Show file tree
Hide file tree
Showing 90 changed files with 53 additions and 42 deletions.
57 changes: 31 additions & 26 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,61 @@ concurrency:
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:

test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
name: Julia ${{ matrix.version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- 'lts'
- '1'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
- 'pre'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-runtest@v1
continue-on-error: ${{ matrix.version == 'nightly' }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
directories: src,test
- uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
slug: Julia-XAI/ExplainableAI.jl

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: doctest
using RelevancePropagation
doctest(RelevancePropagation)'
- run: julia --project=docs docs/make.jl
- uses: julia-actions/cache@v2
- name: Configure doc environment
shell: julia --project=docs --color=yes {0}
run: |
using Pkg
Pkg.Registry.update()
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
DATADEPS_ALWAYS_ACCEPT: true # for MLDatasets download
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
- name: Run doctests
run: |
julia --project=docs --color=yes -e '
using Documenter: doctest
using RelevancePropagation
doctest(RelevancePropagation)'
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RelevancePropagation"
uuid = "0be6dd02-ae9e-43eb-b318-c6e81d6890d8"
authors = ["Adrian Hill <[email protected]>"]
version = "2.0.2"
version = "2.0.3-DEV"

[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
XAIBase = "9b48221d-a747-4c1b-9860-46a1d8ba24a7"
Binary file modified test/references/cnn/CRP_max.jld2
Binary file not shown.
Binary file modified test/references/cnn/CRP_ns1.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPEpsilonAlpha2Beta1Flat_max.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPEpsilonAlpha2Beta1Flat_ns1.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPZero_COC_max.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPZero_COC_ns1.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPZero_max.jld2
Binary file not shown.
Binary file modified test/references/cnn/LRPZero_ns1.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/AlphaBetaRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Dropout.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/GlobalMaxPool.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/GlobalMeanPool.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/MaxPool.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/MeanPool.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/EpsilonRule/flatten.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/FlatRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/GammaRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/GeneralizedGammaRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/LayerNormRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/WSquareRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZBoxRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZPlusRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Conv.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Conv_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Dense_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Dense_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Dropout.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/GlobalMaxPool.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/GlobalMeanPool.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/MaxPool.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/MeanPool.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Scale_identity.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/Scale_relu.jld2
Binary file not shown.
Binary file modified test/references/rules/ZeroRule/flatten.jld2
Binary file not shown.
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ using Test
using JuliaFormatter
using Aqua

@testset "RelevancePropagation.jl" begin
if VERSION >= v"1.10"
@testset verbose = true "RelevancePropagation.jl" begin
@testset verbose = true "Linting" begin
@testset "Code formatting" begin
@info "- Testing code formatting with JuliaFormatter..."
@test JuliaFormatter.format(
Expand Down
9 changes: 5 additions & 4 deletions test/test_batches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ using RelevancePropagation
using Test

using Flux
using Random: rand, MersenneTwister
using Random: rand
using StableRNGs: StableRNG

pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
pseudorand(dims...) = rand(StableRNG(123), Float32, dims...)

## Test `fuse_batchnorm` on Dense and Conv layers
ins = 20
Expand All @@ -14,11 +15,11 @@ batchsize = 15
model = Chain(Dense(ins, outs, relu; init=pseudorand))

# Input 1 w/o batch dimension
input1_no_bd = rand(MersenneTwister(1), Float32, ins)
input1_no_bd = rand(StableRNG(1), Float32, ins)
# Input 1 with batch dimension
input1_bd = reshape(input1_no_bd, ins, 1)
# Input 2 with batch dimension
input2_bd = rand(MersenneTwister(2), Float32, ins, 1)
input2_bd = rand(StableRNG(2), Float32, ins, 1)
# Batch containing inputs 1 & 2
input_batch = cat(input1_bd, input2_bd; dims=2)

Expand Down
3 changes: 2 additions & 1 deletion test/test_canonize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ using Flux
using Flux: flatten, Scale
using RelevancePropagation: canonize_fuse
using Random
using StableRNGs: StableRNG

pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
pseudorand(dims...) = rand(StableRNG(123), Float32, dims...)

batchsize = 50

Expand Down
2 changes: 1 addition & 1 deletion test/test_checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Test
using ReferenceTests

using RelevancePropagation: check_lrp_compat, print_lrp_model_check
using Suppressor
using Suppressor: @suppress

err = ErrorException("Unknown layer or activation function found in model")

Expand Down
7 changes: 4 additions & 3 deletions test/test_cnn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ using ReferenceTests

using Flux
using JLD2
using Random: rand, MersenneTwister
using Random: rand
using StableRNGs: StableRNG

const LRP_ANALYZERS = Dict(
"LRPZero" => LRP,
"LRPZero_COC" => m -> LRP(m; flatten=false), # chain of chains
"LRPEpsilonAlpha2Beta1Flat" => m -> LRP(m, EpsilonAlpha2Beta1Flat()),
)

pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
pseudorand(dims...) = rand(StableRNG(123), Float32, dims...)

input_size = (32, 32, 3, 1)
input = pseudorand(input_size)

init(dims...) = Flux.glorot_uniform(MersenneTwister(123), dims...)
init(dims...) = Flux.glorot_uniform(StableRNG(123), dims...)

model = Chain(
Chain(
Expand Down
5 changes: 3 additions & 2 deletions test/test_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ using RelevancePropagation: stabilize_denom
using Flux
using Flux: flatten, Scale
using LinearAlgebra: I
using Random: randn, MersenneTwister
using Random: randn
using StableRNGs: StableRNG

# Fixed pseudo-random numbers
T = Float32
pseudorandn(dims...) = randn(MersenneTwister(123), T, dims...)
pseudorandn(dims...) = randn(StableRNG(123), T, dims...)

const RULES = Dict(
"ZeroRule" => ZeroRule(),
Expand Down
5 changes: 3 additions & 2 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ using RelevancePropagation: stabilize_denom, drop_batch_index, masked_copy

using Flux
using Flux: flatten, Scale
using Random: rand, MersenneTwister
using Random: rand
using StableRNGs: StableRNG

pseudorand(dims...) = rand(MersenneTwister(123), Float32, dims...)
pseudorand(dims...) = rand(StableRNG(123), Float32, dims...)

# Test `activation_fn`
@test activation_fn(Dense(5, 2, gelu)) == gelu
Expand Down

0 comments on commit 22051fd

Please sign in to comment.