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
|
||||
RNN
|
||||
LSTM
|
||||
Recur
|
||||
Flux.Recur
|
||||
```
|
||||
|
||||
## Activation Functions
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
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
|
||||
```julia
|
||||
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))
|
||||
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]`.
|
||||
`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
|
||||
as an `in × N` matrix. The out `y` will be a vector or batch of length `out`.
|
||||
|
||||
julia> d = Dense(5, 2)
|
||||
Dense(5, 2)
|
||||
```julia
|
||||
julia> d = Dense(5, 2)
|
||||
Dense(5, 2)
|
||||
|
||||
julia> d(rand(5))
|
||||
Tracked 2-element Array{Float64,1}:
|
||||
0.00257447
|
||||
-0.00449443
|
||||
julia> d(rand(5))
|
||||
Tracked 2-element Array{Float64,1}:
|
||||
0.00257447
|
||||
-0.00449443
|
||||
```
|
||||
"""
|
||||
struct Dense{F,S,T}
|
||||
σ::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.
|
||||
|
||||
accum(h, x) = (h+x, x)
|
||||
rnn = Flux.Recur(accum, 0)
|
||||
rnn(2) # 2
|
||||
rnn(3) # 3
|
||||
rnn.state # 5
|
||||
rnn.(1:10) # apply to a sequence
|
||||
rnn.state # 60
|
||||
```julia
|
||||
accum(h, x) = (h+x, x)
|
||||
rnn = Flux.Recur(accum, 0)
|
||||
rnn(2) # 2
|
||||
rnn(3) # 3
|
||||
rnn.state # 5
|
||||
rnn.(1:10) # apply to a sequence
|
||||
rnn.state # 60
|
||||
```
|
||||
"""
|
||||
mutable struct Recur{T}
|
||||
cell::T
|
||||
|
|
Loading…
Reference in New Issue