layer docs

This commit is contained in:
Mike J Innes 2017-09-08 17:52:41 -04:00
parent ef61922dde
commit a36d6d2af3
3 changed files with 29 additions and 3 deletions

View File

@ -9,11 +9,13 @@ makedocs(modules=[Flux],
pages = ["Home" => "index.md",
"Models" =>
["Basics" => "models/basics.md",
"Recurrence" => "models/recurrence.md"],
"Recurrence" => "models/recurrence.md",
"Layers" => "models/layers.md"],
"Contributing & Help" => "contributing.md"])
deploydocs(
repo = "github.com/FluxML/Flux.jl.git",
modules = [Flux],
target = "build",
osname = "linux",
julia = "0.6",

View File

@ -0,0 +1,6 @@
## Model Layers
```@docs
Chain
Dense
```

View File

@ -1,5 +1,18 @@
# Chain
"""
Chain(layers...)
Chain multiple layers / functions together, so that they are called in sequence
on a given input.
m = Chain(x -> x^2, x -> x+1)
m(5) == 26
m = Chain(Dense(10, 5), Dense(5, 2))
x = rand(10)
m(x) = m[2](m[1](x))
`Chain` also supports indexing and slicing, e.g. `m[2]` or `m[1:end-1]`.
"""
type Chain
layers::Vector{Any}
Chain(xs...) = new([xs...])
@ -23,8 +36,13 @@ function Base.show(io::IO, c::Chain)
print(io, ")")
end
# Dense
"""
Dense(in::Integer, out::Integer, σ = identity)
Creates a traditional `Dense` layer with parameters `W` and `b`.
y = σ.(W * x .+ b)
"""
struct Dense{F,S,T}
σ::F
W::S