From 99100b85545d01faec58f44570651cf86eec0d8e Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 2 May 2024 08:57:02 +1200 Subject: [PATCH] use default_rng when comparing acceleration methods --- test/classifier.jl | 3 +-- test/image.jl | 6 +++--- test/regressor.jl | 4 ++-- test/test_utils.jl | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/classifier.jl b/test/classifier.jl index 3c9f3fe9..df2d2f55 100644 --- a/test/classifier.jl +++ b/test/classifier.jl @@ -62,9 +62,8 @@ losses = [] # check flux model is an improvement on predicting constant # distribution # (GPUs only support `default_rng`): - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) - rng = StableRNGs.StableRNG(123) model = MLJFlux.NeuralNetworkClassifier(epochs=50, builder=builder, optimiser=optimiser, diff --git a/test/image.jl b/test/image.jl index 18aef194..5c0bb5bd 100644 --- a/test/image.jl +++ b/test/image.jl @@ -33,7 +33,7 @@ losses = [] @testset_accelerated "ImageClassifier basic tests" accel begin # GPUs only support `default_rng`: - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) model = MLJFlux.ImageClassifier(builder=builder, @@ -86,7 +86,7 @@ losses = [] @testset_accelerated "ColorImages" accel begin # GPUs only support `default_rng`: - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) model = MLJFlux.ImageClassifier(builder=builder, @@ -129,7 +129,7 @@ noise=0.2, color=true); @testset_accelerated "ImageClassifier basic tests" accel begin # GPUs only support `default_rng`: - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) model = MLJFlux.ImageClassifier(epochs=5, diff --git a/test/regressor.jl b/test/regressor.jl index f5d1f783..f40ea171 100644 --- a/test/regressor.jl +++ b/test/regressor.jl @@ -42,7 +42,7 @@ train, test = MLJBase.partition(1:N, 0.7) # test model is a bit better than constant predictor: # (GPUs only support `default_rng`): - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) model = MLJFlux.NeuralNetworkRegressor(builder=builder, acceleration=accel, @@ -108,7 +108,7 @@ losses = [] # test model is a bit better than constant predictor # (GPUs only support `default_rng`): - rng = accel == CPU1() ? StableRNGs.StableRNG(123) : Random.default_rng() + rng = Random.default_rng() seed!(rng, 123) model = MLJFlux.MultitargetNeuralNetworkRegressor( acceleration=accel, diff --git a/test/test_utils.jl b/test/test_utils.jl index 5a652bbf..63341e2d 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -164,7 +164,6 @@ function optimisertest(ModelType, X, y, builder, optimiser, accel) @test isapprox(l1, l2) else @test_broken isapprox(l1, l2, rtol=1e-8) - @show l1/l2 end # USING USER SPECIFIED RNG SEED (unsupported on GPU)