syntax highlighting
This commit is contained in:
parent
fd249b773e
commit
b817ce632c
@ -14,7 +14,7 @@ Much like the core layers above, but can be used to process sequence data (as we
|
|||||||
```@docs
|
```@docs
|
||||||
RNN
|
RNN
|
||||||
LSTM
|
LSTM
|
||||||
Recur
|
Flux.Recur
|
||||||
```
|
```
|
||||||
|
|
||||||
## Activation Functions
|
## Activation Functions
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
Chain multiple layers / functions together, so that they are called in sequence
|
Chain multiple layers / functions together, so that they are called in sequence
|
||||||
on a given input.
|
on a given input.
|
||||||
|
|
||||||
m = Chain(x -> x^2, x -> x+1)
|
```julia
|
||||||
m(5) == 26
|
m = Chain(x -> x^2, x -> x+1)
|
||||||
|
m(5) == 26
|
||||||
|
|
||||||
m = Chain(Dense(10, 5), Dense(5, 2))
|
m = Chain(Dense(10, 5), Dense(5, 2))
|
||||||
x = rand(10)
|
x = rand(10)
|
||||||
m(x) == m[2](m[1](x))
|
m(x) == m[2](m[1](x))
|
||||||
|
```
|
||||||
|
|
||||||
`Chain` also supports indexing and slicing, e.g. `m[2]` or `m[1:end-1]`.
|
`Chain` also supports indexing and slicing, e.g. `m[2]` or `m[1:end-1]`.
|
||||||
`m[1:3](x)` will calculate the output of the first three layers.
|
`m[1:3](x)` will calculate the output of the first three layers.
|
||||||
@ -45,13 +47,15 @@ Creates a traditional `Dense` layer with parameters `W` and `b`.
|
|||||||
The input `x` must be a vector of length `in`, or a batch of vectors represented
|
The input `x` must be a vector of length `in`, or a batch of vectors represented
|
||||||
as an `in × N` matrix. The out `y` will be a vector or batch of length `out`.
|
as an `in × N` matrix. The out `y` will be a vector or batch of length `out`.
|
||||||
|
|
||||||
julia> d = Dense(5, 2)
|
```julia
|
||||||
Dense(5, 2)
|
julia> d = Dense(5, 2)
|
||||||
|
Dense(5, 2)
|
||||||
|
|
||||||
julia> d(rand(5))
|
julia> d(rand(5))
|
||||||
Tracked 2-element Array{Float64,1}:
|
Tracked 2-element Array{Float64,1}:
|
||||||
0.00257447
|
0.00257447
|
||||||
-0.00449443
|
-0.00449443
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
struct Dense{F,S,T}
|
struct Dense{F,S,T}
|
||||||
σ::F
|
σ::F
|
||||||
|
@ -13,13 +13,15 @@ in the background. `cell` should be a model of the form:
|
|||||||
|
|
||||||
For example, here's a recurrent network that keeps a running total of its inputs.
|
For example, here's a recurrent network that keeps a running total of its inputs.
|
||||||
|
|
||||||
accum(h, x) = (h+x, x)
|
```julia
|
||||||
rnn = Flux.Recur(accum, 0)
|
accum(h, x) = (h+x, x)
|
||||||
rnn(2) # 2
|
rnn = Flux.Recur(accum, 0)
|
||||||
rnn(3) # 3
|
rnn(2) # 2
|
||||||
rnn.state # 5
|
rnn(3) # 3
|
||||||
rnn.(1:10) # apply to a sequence
|
rnn.state # 5
|
||||||
rnn.state # 60
|
rnn.(1:10) # apply to a sequence
|
||||||
|
rnn.state # 60
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
mutable struct Recur{T}
|
mutable struct Recur{T}
|
||||||
cell::T
|
cell::T
|
||||||
|
Loading…
Reference in New Issue
Block a user