From 7f36ece7c35e838f2223a64d3c3554eccb8ed0ff Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Tue, 17 Oct 2023 06:25:09 +1100 Subject: [PATCH 1/7] bump to Metalhead 0.9 --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index cac18ad2..462fd8bf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJFlux" uuid = "094fc8d1-fd35-5302-93ea-dabda2abf845" authors = ["Anthony D. Blaom ", "Ayush Shridhar "] -version = "0.3.1" +version = "0.4.0" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" @@ -21,7 +21,7 @@ ColorTypes = "0.10.3, 0.11" ComputationalResources = "0.3.2" Flux = "0.13, 0.14" MLJModelInterface = "1.1.1" -Metalhead = "0.8" +Metalhead = "0.9" ProgressMeter = "1.7.1" Tables = "1.0" julia = "1.6" From 91e809ed0a3b737517f1df5fef99be516b236b53 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Tue, 17 Oct 2023 06:43:37 +1100 Subject: [PATCH 2/7] add CUDA compat line --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 462fd8bf..23b98afb 100644 --- a/Project.toml +++ b/Project.toml @@ -18,6 +18,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] CategoricalArrays = "0.10" ColorTypes = "0.10.3, 0.11" +CUDA = "4" ComputationalResources = "0.3.2" Flux = "0.13, 0.14" MLJModelInterface = "1.1.1" From 3d380c470b21ef6946e4a5466504d6c4f7175c95 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Tue, 17 Oct 2023 06:47:09 +1100 Subject: [PATCH 3/7] add CUDA as extra --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 23b98afb..221f1a67 100644 --- a/Project.toml +++ b/Project.toml @@ -28,6 +28,7 @@ Tables = "1.0" julia = "1.6" [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" From d3abf528fcc5c71500fdb7c4ff18abd232e77456 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Tue, 17 Oct 2023 06:56:26 +1100 Subject: [PATCH 4/7] remove CUDA again --- Project.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Project.toml b/Project.toml index 221f1a67..462fd8bf 100644 --- a/Project.toml +++ b/Project.toml @@ -18,7 +18,6 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] CategoricalArrays = "0.10" ColorTypes = "0.10.3, 0.11" -CUDA = "4" ComputationalResources = "0.3.2" Flux = "0.13, 0.14" MLJModelInterface = "1.1.1" @@ -28,7 +27,6 @@ Tables = "1.0" julia = "1.6" [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" From 62833f4d80c2a2ae6427b566c1655070ec52e2ae Mon Sep 17 00:00:00 2001 From: mohamed82008 Date: Tue, 17 Oct 2023 12:07:43 +1100 Subject: [PATCH 5/7] fix tests --- Project.toml | 6 ++++-- test/builders.jl | 2 +- test/classifier.jl | 4 ++-- test/integration.jl | 6 +++--- test/mlj_model_interface.jl | 2 +- test/runtests.jl | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index 462fd8bf..ba5366cd 100644 --- a/Project.toml +++ b/Project.toml @@ -19,10 +19,11 @@ 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.9" ProgressMeter = "1.7.1" +StatisticalMeasures = "0.1" Tables = "1.0" julia = "1.6" @@ -32,9 +33,10 @@ 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 = ["cuDNN", "LinearAlgebra", "MLJBase", "Random", "StableRNGs", "StatisticalMeasures", "Statistics", "StatsBase", "Test"] diff --git a/test/builders.jl b/test/builders.jl index 0f7e27a9..ba7df095 100644 --- a/test/builders.jl +++ b/test/builders.jl @@ -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: diff --git a/test/classifier.jl b/test/classifier.jl index 3eb73699..82de9500 100644 --- a/test/classifier.jl +++ b/test/classifier.jl @@ -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: @@ -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, diff --git a/test/integration.jl b/test/integration.jl index 70b45fd1..39f4f79c 100644 --- a/test/integration.jl +++ b/test/integration.jl @@ -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 diff --git a/test/mlj_model_interface.jl b/test/mlj_model_interface.jl index a2e6c8fe..52452ea5 100644 --- a/test/mlj_model_interface.jl +++ b/test/mlj_model_interface.jl @@ -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() diff --git a/test/runtests.jl b/test/runtests.jl index 691edb89..31a1c5a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,7 +10,7 @@ import Random.seed! using Statistics import StatsBase using StableRNGs -using cuDNN +import StatisticalMeasures using ComputationalResources using ComputationalResources: CPU1, CUDALibs From fb48be29ada66fe73186feb518781a4b4bdd32b6 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Tue, 17 Oct 2023 13:50:18 +1100 Subject: [PATCH 6/7] Update Project.toml Co-authored-by: Anthony Blaom, PhD --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ba5366cd..efed5bed 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ Metalhead = "0.9" ProgressMeter = "1.7.1" StatisticalMeasures = "0.1" Tables = "1.0" -julia = "1.6" +julia = "1.9" [extras] cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" From dbcfdc8f10c3d4508fddec4b7039d064abef26e8 Mon Sep 17 00:00:00 2001 From: mohamed82008 Date: Tue, 17 Oct 2023 14:55:09 +1100 Subject: [PATCH 7/7] fix frozen tests --- Project.toml | 3 ++- test/runtests.jl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index efed5bed..589216d8 100644 --- a/Project.toml +++ b/Project.toml @@ -28,6 +28,7 @@ Tables = "1.0" 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" @@ -39,4 +40,4 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["cuDNN", "LinearAlgebra", "MLJBase", "Random", "StableRNGs", "StatisticalMeasures", "Statistics", "StatsBase", "Test"] +test = ["CUDA", "cuDNN", "LinearAlgebra", "MLJBase", "Random", "StableRNGs", "StatisticalMeasures", "Statistics", "StatsBase", "Test"] diff --git a/test/runtests.jl b/test/runtests.jl index 31a1c5a1..d8df35be 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,7 @@ import Random.seed! using Statistics import StatsBase using StableRNGs +using CUDA, cuDNN import StatisticalMeasures using ComputationalResources