Skip to content

Commit

Permalink
bump functors compat (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Apr 20, 2023
1 parent 8707055 commit 27acd1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LegolasFlux"
uuid = "eb5f792d-d1b1-4535-bae3-d5649ec7daa4"
authors = ["Beacon Biosignals, Inc."]
version = "0.2.1"
version = "0.2.2"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand All @@ -12,7 +12,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
[compat]
Arrow = "1, 2"
Flux = "0.12, 0.13"
Functors = "0.2.6, 0.3"
Functors = "0.2.6, 0.3, 0.4"
Legolas = "0.5"
Tables = "1"
julia = "1.6"
Expand Down
9 changes: 8 additions & 1 deletion examples/digits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Flux.@functor DigitsModel (chain,)
function DigitsModel(config::DigitsConfigV1=DigitsConfigV1())
dropout_rate = config.dropout_rate
Random.seed!(config.seed)
D = Dense(10, 10)
chain = Chain(Dropout(dropout_rate),
Conv((3, 3), 1 => 32, relu),
BatchNorm(32, relu),
Expand All @@ -51,6 +52,8 @@ function DigitsModel(config::DigitsConfigV1=DigitsConfigV1())
x -> reshape(x, :, size(x, 4)),
Dropout(dropout_rate),
Dense(90, 10),
D,
D, # same layer twice, to test weight-sharing
softmax)
return DigitsModel(chain, config)
end
Expand Down Expand Up @@ -141,6 +144,7 @@ function train_model!(m; N=N_train)
end

m = DigitsModel()
@test m.chain[end-2] === m.chain[end-1] # test weight sharing

# increase N to actually train more than a tiny amount
acc = train_model!(m; N=10)
Expand Down Expand Up @@ -174,8 +178,11 @@ roundtripped_model = DigitsModel(roundtripped)
output3 = roundtripped_model(input)
@test output3 isa Matrix{Float32}

# Test we are still weight-sharing post-roundtrip
@test roundtripped_model.chain[end-2] === roundtripped_model.chain[end-1]

# Here, we've hardcoded the results at the time of serialization.
# This lets us check that the model we've saved gives the same answers now as it did then.
# It is OK to update this test w/ a new reference if the answers are *supposed* to change for some reason. Just make sure that is the case.
@test output3
Float32[0.09915658; 0.100575574; 0.101189725; 0.10078623; 0.09939819; 0.099650174; 0.1013182; 0.09952383; 0.0991391; 0.09926238;;]
Float32[0.096030906; 0.105671346; 0.09510324; 0.117868274; 0.112540945; 0.08980863; 0.062402092; 0.09776583; 0.11317684; 0.109631866;;]
Binary file modified examples/test.digits-model.arrow
Binary file not shown.

2 comments on commit 27acd1b

@ericphanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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/82004

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 v0.2.2 -m "<description of version>" 27acd1bd20e5b335794fbf4c5cade46cc75c54c6
git push origin v0.2.2

Please sign in to comment.