From df84628c299ecd7732649fcefb75027b766b4e97 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 10 Jun 2020 12:06:57 +0100 Subject: [PATCH 1/7] Require weight and bias to be AbstractArrays --- src/layers/basic.jl | 2 +- test/layers/basic.jl | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/layers/basic.jl b/src/layers/basic.jl index 4754467d..bc536c9d 100644 --- a/src/layers/basic.jl +++ b/src/layers/basic.jl @@ -102,7 +102,7 @@ julia> d(rand(5)) -0.16210233 0.12311903``` """ -struct Dense{F,S,T} +struct Dense{F,S<:AbstractArray,T<:AbstractArray} W::S b::T σ::F diff --git a/test/layers/basic.jl b/test/layers/basic.jl index 421c7721..11114267 100644 --- a/test/layers/basic.jl +++ b/test/layers/basic.jl @@ -28,6 +28,13 @@ import Flux: activations end @testset "Dense" begin + @testset "constructors" begin + @test size(Dense(10, 100).W) == (100, 10) + @test Dense(rand(100,10), rand(10)).σ == identity + + @test_throws MethodError Dense(10, 10.5) + end + @test length(Dense(10, 5)(randn(10))) == 5 @test_throws DimensionMismatch Dense(10, 5)(randn(1)) @test_throws MethodError Dense(10, 5)(1) # avoid broadcasting @@ -37,7 +44,6 @@ import Flux: activations @test Dense(10, 1, identity, initW = ones, initb = zeros)(ones(10,2)) == 10*ones(1, 2) @test Dense(10, 2, identity, initW = ones, initb = zeros)(ones(10,1)) == 10*ones(2, 1) @test Dense(10, 2, identity, initW = ones, initb = zeros)([ones(10,1) 2*ones(10,1)]) == [10 20; 10 20] - end @testset "Diagonal" begin From cf90517a8a99484e2054ba51e894ee7b1fdd6b4c Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 10 Jun 2020 12:14:19 +0100 Subject: [PATCH 2/7] update news.md --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 82c1dcfd..1073068d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# v0.11.1 +* Error if Dense layers weights and biases are not arrays [https://github.com/FluxML/Flux.jl/pull/1218]. + # v0.11 * Change to `DataLoader`'s constructor [https://github.com/FluxML/Flux.jl/pull/1152] From 97b0aa4d36015df2031d54bf0c8b124188473cad Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 10 Jun 2020 12:14:47 +0100 Subject: [PATCH 3/7] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 96999124..ec20eec5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Flux" uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" -version = "0.11.0" +version = "0.11.1" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" From 15c7354c4e248884ec2d94c802ba43ac7c0aab67 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 10 Jun 2020 12:38:33 +0100 Subject: [PATCH 4/7] Make release as DEV --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ec20eec5..d94b8333 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Flux" uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" -version = "0.11.1" +version = "0.11.0-DEV" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" From a1623aca76af46c53aa2107139d58c466412e15f Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Wed, 10 Jun 2020 12:39:00 +0100 Subject: [PATCH 5/7] move into 0.11 news --- NEWS.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1073068d..def86ff2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,6 @@ -# v0.11.1 -* Error if Dense layers weights and biases are not arrays [https://github.com/FluxML/Flux.jl/pull/1218]. - # v0.11 * Change to `DataLoader`'s constructor [https://github.com/FluxML/Flux.jl/pull/1152] +* Error if Dense layers weights and biases are not arrays [https://github.com/FluxML/Flux.jl/pull/1218]. # v0.10.5 * Add option for [same padding](https://github.com/FluxML/Flux.jl/pull/901) to conv and pooling layers by setting `pad=SamePad()`. From 601f842eaf4717a5d55e8a47738aea9fd5713a66 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Thu, 11 Jun 2020 23:17:40 +0100 Subject: [PATCH 6/7] bonus test --- test/layers/basic.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/layers/basic.jl b/test/layers/basic.jl index 11114267..1c869c30 100644 --- a/test/layers/basic.jl +++ b/test/layers/basic.jl @@ -33,6 +33,7 @@ import Flux: activations @test Dense(rand(100,10), rand(10)).σ == identity @test_throws MethodError Dense(10, 10.5) + @test_throws MethodError Dense(10, 10.5; σ=tanh) end @test length(Dense(10, 5)(randn(10))) == 5 From e61787c1c8eb58b0aacc9b0b9380ee4fa44efdad Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Fri, 12 Jun 2020 13:58:10 +0100 Subject: [PATCH 7/7] Update test/layers/basic.jl --- test/layers/basic.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/layers/basic.jl b/test/layers/basic.jl index 1c869c30..013b21b0 100644 --- a/test/layers/basic.jl +++ b/test/layers/basic.jl @@ -33,7 +33,7 @@ import Flux: activations @test Dense(rand(100,10), rand(10)).σ == identity @test_throws MethodError Dense(10, 10.5) - @test_throws MethodError Dense(10, 10.5; σ=tanh) + @test_throws MethodError Dense(10, 10.5, tanh) end @test length(Dense(10, 5)(randn(10))) == 5