syntax highlighting

This commit is contained in:
Mike J Innes 2017-10-18 15:44:06 +01:00
parent fd249b773e
commit b817ce632c
3 changed files with 25 additions and 19 deletions

View File

@ -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

View File

@ -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.
```julia
m = Chain(x -> x^2, x -> x+1) m = Chain(x -> x^2, x -> x+1)
m(5) == 26 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,6 +47,7 @@ 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
julia> d = Dense(5, 2) julia> d = Dense(5, 2)
Dense(5, 2) Dense(5, 2)
@ -52,6 +55,7 @@ as an `in × N` matrix. The out `y` will be a vector or batch of length `out`.
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

View File

@ -13,6 +13,7 @@ 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.
```julia
accum(h, x) = (h+x, x) accum(h, x) = (h+x, x)
rnn = Flux.Recur(accum, 0) rnn = Flux.Recur(accum, 0)
rnn(2) # 2 rnn(2) # 2
@ -20,6 +21,7 @@ For example, here's a recurrent network that keeps a running total of its inputs
rnn.state # 5 rnn.state # 5
rnn.(1:10) # apply to a sequence rnn.(1:10) # apply to a sequence
rnn.state # 60 rnn.state # 60
```
""" """
mutable struct Recur{T} mutable struct Recur{T}
cell::T cell::T