Skip to content

Commit

Permalink
Merge pull request #243 from FluxML/dev
Browse files Browse the repository at this point in the history
For a 0.4.0 release
  • Loading branch information
ablaom authored Oct 17, 2023
2 parents ab630f5 + caed27b commit 8eaed13
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
13 changes: 8 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJFlux"
uuid = "094fc8d1-fd35-5302-93ea-dabda2abf845"
authors = ["Anthony D. Blaom <[email protected]>", "Ayush Shridhar <[email protected]>"]
version = "0.3.1"
version = "0.4.0"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand All @@ -19,22 +19,25 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
CategoricalArrays = "0.10"
ColorTypes = "0.10.3, 0.11"
ComputationalResources = "0.3.2"
Flux = "0.13, 0.14"
Flux = "0.14"
MLJModelInterface = "1.1.1"
Metalhead = "0.8"
Metalhead = "0.9"
ProgressMeter = "1.7.1"
StatisticalMeasures = "0.1"
Tables = "1.0"
julia = "1.6"
julia = "1.9"

[extras]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StatisticalMeasures = "a19d573c-0a75-4610-95b3-7071388c7541"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["cuDNN", "LinearAlgebra", "MLJBase", "Random", "StableRNGs", "Statistics", "StatsBase", "Test"]
test = ["CUDA", "cuDNN", "LinearAlgebra", "MLJBase", "Random", "StableRNGs", "StatisticalMeasures", "Statistics", "StatsBase", "Test"]
2 changes: 1 addition & 1 deletion test/builders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MLJFlux.build(builder::TESTBuilder, rng, n_in, n_out) =
chain0 = myinit(1, d)
pretraining_yhat = Xmat*chain0' |> vec
@test y isa Vector && pretraining_yhat isa Vector
pretraining_loss_by_hand = MLJBase.l2(pretraining_yhat, y) |> mean
pretraining_loss_by_hand = StatisticalMeasures.l2(pretraining_yhat, y) |> mean
mean(((pretraining_yhat - y).^2)[1:2])

# compare:
Expand Down
4 changes: 2 additions & 2 deletions test/classifier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ losses = []
end
dist = MLJBase.UnivariateFinite(prob_given_class)
loss_baseline =
MLJBase.cross_entropy(fill(dist, length(test)), y[test]) |> mean
StatisticalMeasures.cross_entropy(fill(dist, length(test)), y[test]) |> mean

# check flux model is an improvement on predicting constant
# distribution:
Expand All @@ -71,7 +71,7 @@ losses = []
first_last_training_loss = MLJBase.report(mach)[1][[1, end]]
push!(losses, first_last_training_loss[2])
yhat = MLJBase.predict(mach, rows=test);
@test mean(MLJBase.cross_entropy(yhat, y[test])) < 0.95*loss_baseline
@test mean(StatisticalMeasures.cross_entropy(yhat, y[test])) < 0.95*loss_baseline

optimisertest(MLJFlux.NeuralNetworkClassifier,
X,
Expand Down
6 changes: 3 additions & 3 deletions test/integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ y, X = unpack(table, ==(:target), _->true, rng=rng)
model3 = deepcopy(model)
model3.lambda = 0.1

e = evaluate(model, X, y, resampling=Holdout(), measure=LogLoss())
e = evaluate(model, X, y, resampling=Holdout(), measure=StatisticalMeasures.LogLoss())
loss1 = e.measurement[1]

e = evaluate(model2, X, y, resampling=Holdout(), measure=LogLoss())
e = evaluate(model2, X, y, resampling=Holdout(), measure=StatisticalMeasures.LogLoss())
loss2 = e.measurement[1]

e = evaluate(model3, X, y, resampling=Holdout(), measure=LogLoss())
e = evaluate(model3, X, y, resampling=Holdout(), measure=StatisticalMeasures.LogLoss())
loss3 = e.measurement[1]

@test loss1 loss2
Expand Down
2 changes: 1 addition & 1 deletion test/mlj_model_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
@test model.batch_size == 1

if MLJFlux.gpu_isdead()
model = @test_logs (:warn, r"`acceleration") begin
model = @test_logs (:warn, r"`acceleration") match_mode = :any begin
ModelType(acceleration=CUDALibs())
end
@test model.acceleration == CUDALibs()
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Random.seed!
using Statistics
import StatsBase
using StableRNGs
using cuDNN
using CUDA, cuDNN
import StatisticalMeasures

using ComputationalResources
using ComputationalResources: CPU1, CUDALibs
Expand Down

0 comments on commit 8eaed13

Please sign in to comment.