Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Metalhead to 0.9 - making CUDA optional #240

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 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,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.8"
Metalhead = "0.9"
ProgressMeter = "1.7.1"
StatisticalMeasures = "0.1"
Tables = "1.0"
julia = "1.6"
mohamed82008 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -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"]
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
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Random.seed!
using Statistics
import StatsBase
using StableRNGs
using cuDNN
mohamed82008 marked this conversation as resolved.
Show resolved Hide resolved
import StatisticalMeasures

using ComputationalResources
using ComputationalResources: CPU1, CUDALibs
Expand Down