@@ -2,7 +2,7 @@ using Flux
2
2
using Flux: throttle, nfan, glorot_uniform, glorot_normal,
3
3
kaiming_normal, kaiming_uniform, orthogonal, truncated_normal,
4
4
sparse_init, identity_init, stack, unstack, batch, unbatch,
5
- unsqueeze, params, loadparams !
5
+ unsqueeze, params, loadmodel !
6
6
using StatsBase: var, std
7
7
using Statistics, LinearAlgebra
8
8
using Random
@@ -366,14 +366,14 @@ end
366
366
@test_skip typeof (l1. bias) === typeof (l2. bias)
367
367
end
368
368
369
- @testset " loadparams !" begin
369
+ @testset " loadmodel !" begin
370
370
pars (w, b) = [w, b]
371
371
pars (l) = pars (l. weight, l. bias)
372
372
pararray (m) = mapreduce (pars, vcat, m)
373
373
weights (m) = mapreduce (l -> [l. weight], vcat, m)
374
374
@testset " Bias type $bt " for bt in (Flux. zeros32, nobias)
375
375
m = dm (bt)
376
- loadmodel! (m, params (m))
376
+ Flux . loadmodel! (m, params (m))
377
377
testdense (m, bt)
378
378
end
379
379
end
@@ -421,22 +421,22 @@ end
421
421
end
422
422
end
423
423
424
- @testset " loadparams ! & absent bias" begin
424
+ @testset " loadmodel ! & absent bias" begin
425
425
m0 = Chain (Dense (2 => 3 ; bias= false , init = Flux. ones32), Dense (3 => 1 ))
426
426
m1 = Chain (Dense (2 => 3 ; bias = Flux. randn32 (3 )), Dense (3 => 1 ))
427
427
m2 = Chain (Dense (Float32[1 2 ; 3 4 ; 5 6 ], Float32[7 , 8 , 9 ]), Dense (3 => 1 ))
428
428
429
- Flux. loadparams ! (m1, Flux . params (m2) )
429
+ Flux. loadmodel ! (m1, m2 )
430
430
@test m1[1 ]. bias == 7 : 9
431
431
@test sum (m1[1 ]. weight) == 21
432
432
433
433
# load from a model without bias -- should ideally recognise the `false` but `Params` doesn't store it
434
- @test_broken Flux. loadparams ! (m1, Flux . params (m0) )
435
- @test_broken iszero (m1[1 ]. bias)
434
+ m1 = Flux. loadmodel ! (m1, m0 )
435
+ @test iszero (m1[1 ]. bias)
436
436
@test sum (m1[1 ]. weight) == 6 # written before error
437
437
438
438
# load into a model without bias -- should it ignore the parameter which has no home, or error?
439
- @test_broken Flux. loadparams ! (m0, Flux . params (m2) )
439
+ m0 = Flux. loadmodel ! (m0, m2 )
440
440
@test iszero (m0[1 ]. bias) # obviously unchanged
441
441
@test sum (m0[1 ]. weight) == 21
442
442
end
0 commit comments