correct casing

This commit is contained in:
Lyndon White 2019-03-06 10:22:46 -08:00
parent e23c8ddd13
commit ca68bf9bec
2 changed files with 15 additions and 15 deletions

View File

@ -127,9 +127,9 @@ end
""" """
MaxOut(over) Maxout(over)
`MaxOut` is a neural network layer, which has a number of internal layers, `Maxout` is a neural network layer, which has a number of internal layers,
which all have the same input, and the max out returns the elementwise maximium which all have the same input, and the max out returns the elementwise maximium
of the internal layers' outputs. of the internal layers' outputs.
@ -142,30 +142,30 @@ In Proceedings of the 30th International Conference on International Conference
Sanjoy Dasgupta and David McAllester (Eds.), Vol. 28. JMLR.org III-1319-III-1327. Sanjoy Dasgupta and David McAllester (Eds.), Vol. 28. JMLR.org III-1319-III-1327.
https://arxiv.org/pdf/1302.4389.pdf https://arxiv.org/pdf/1302.4389.pdf
""" """
struct MaxOut{FS<:Tuple} struct Maxout{FS<:Tuple}
over::FS over::FS
end end
""" """
MaxOut(f, n_alts, args...; kwargs...) Maxout(f, n_alts, args...; kwargs...)
Constructs a MaxOut layer over `n_alts` instances of the layer given by `f`. Constructs a Maxout layer over `n_alts` instances of the layer given by `f`.
All other arguements (`args` & `kwargs`) are passed to the constructor `f`. All other arguements (`args` & `kwargs`) are passed to the constructor `f`.
For example the following example which For example the following example which
will construct a `MaxOut` layer over 4 dense linear layers, will construct a `Maxout` layer over 4 dense linear layers,
each identical in structure (784 inputs, 128 outputs). each identical in structure (784 inputs, 128 outputs).
```julia ```julia
insize = 784 insize = 784
outsie = 128 outsie = 128
MaxOut(Dense, 4, insize, outsize) Maxout(Dense, 4, insize, outsize)
``` ```
""" """
function MaxOut(f, n_alts, args...; kwargs...) function Maxout(f, n_alts, args...; kwargs...)
over = Tuple(f(args...; kwargs...) for _ in 1:n_alts) over = Tuple(f(args...; kwargs...) for _ in 1:n_alts)
return MaxOut(over) return Maxout(over)
end end
function (mo::MaxOut)(input::AbstractArray) function (mo::Maxout)(input::AbstractArray)
mapreduce(f -> f(input), (acc, out) -> max.(acc, out), mo.over) mapreduce(f -> f(input), (acc, out) -> max.(acc, out), mo.over)
end end

View File

@ -31,24 +31,24 @@ using Test, Random
@test Flux.Diagonal(2)([1 2; 3 4]) == [1 2; 3 4] @test Flux.Diagonal(2)([1 2; 3 4]) == [1 2; 3 4]
end end
@testset "MaxOut" begin @testset "Maxout" begin
# Note that the normal common usage of MaxOut is as per the docstring # Note that the normal common usage of Maxout is as per the docstring
# These are abnormal constructors used for testing purposes # These are abnormal constructors used for testing purposes
@testset "Constructor" begin @testset "Constructor" begin
mo = MaxOut(() -> identity, 4) mo = Maxout(() -> identity, 4)
input = rand(40) input = rand(40)
@test mo(input) == input @test mo(input) == input
end end
@testset "simple alternatives" begin @testset "simple alternatives" begin
mo = MaxOut((x -> x, x -> 2x, x -> 0.5x)) mo = Maxout((x -> x, x -> 2x, x -> 0.5x))
input = rand(40) input = rand(40)
@test mo(input) == 2*input @test mo(input) == 2*input
end end
@testset "complex alternatives" begin @testset "complex alternatives" begin
mo = MaxOut((x -> [0.5; 0.1]*x, x -> [0.2; 0.7]*x)) mo = Maxout((x -> [0.5; 0.1]*x, x -> [0.2; 0.7]*x))
input = [3.0 2.0] input = [3.0 2.0]
target = [0.5, 0.7].*input target = [0.5, 0.7].*input
@test mo(input) == target @test mo(input) == target