4</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L46-L74">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.stack"href="#Flux.stack"><code>Flux.stack</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">stack(xs, dim)</code></pre><p>Concatenate the given <code>Array</code> of <code>Array</code>s <code>xs</code> into a single <code>Array</code> along the given dimension <code>dim</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> xs = [[1, 2], [3, 4], [5, 6]]
[5, 6]</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L77-L103">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.unstack"href="#Flux.unstack"><code>Flux.unstack</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">unstack(xs, dim)</code></pre><p>Unroll the given <code>xs</code> into an <code>Array</code> of <code>Array</code>s along the given dimension <code>dim</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.unstack([1 3 5 7; 2 4 6 8], 2)
[9, 10]</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L123-L142">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.frequencies"href="#Flux.frequencies"><code>Flux.frequencies</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">frequencies(xs)</code></pre><p>Count the number of times that each element of <code>xs</code> appears.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.frequencies(['a','b','b'])
'b' => 2</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L147-L159">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.batch"href="#Flux.batch"><code>Flux.batch</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">batch(xs)</code></pre><p>Batch the arrays in <code>xs</code> into a single array.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.batch([[1,2,3],[4,5,6]])
3 6</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L172-L185">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.batchseq"href="#Flux.batchseq"><code>Flux.batchseq</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">batchseq(seqs, pad)</code></pre><p>Take a list of <code>N</code> sequences, and turn them into a single sequence where each item is a batch of <code>N</code>. Short sequences will be padded by <code>pad</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.batchseq([[1, 2, 3], [4, 5]], 0)
[3, 0]</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L217-L231">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Base.rpad-Tuple{AbstractArray{T,1} where T,Integer,Any}"href="#Base.rpad-Tuple{AbstractArray{T,1} where T,Integer,Any}"><code>Base.rpad</code></a> — <spanclass="docstring-category">Method</span></header><section><div><p>Return the given sequence padded with <code>p</code> up to a maximum length of <code>n</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> rpad([1, 2], 4, 0)
3</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L196-L214">source</a></section></article><h2id="Layer-Initialization-1"><aclass="docs-heading-anchor"href="#Layer-Initialization-1">Layer Initialization</a><aclass="docs-heading-anchor-permalink"href="#Layer-Initialization-1"title="Permalink"></a></h2><p>These are primarily useful if you are planning to write your own layers. Flux initializes convolutional layers and recurrent cells with <code>glorot_uniform</code> by default. To change the default on an applicable layer, pass the desired function with the <code>init</code> keyword. For example:</p><pre><codeclass="language-julia-repl">julia> conv = Conv((3, 3), 1 => 8, relu; init=Flux.glorot_normal)
Conv((3, 3), 1=>8, relu)</code></pre><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.glorot_uniform"href="#Flux.glorot_uniform"><code>Flux.glorot_uniform</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">glorot_uniform(dims...)</code></pre><p>Return an <code>Array</code> of size <code>dims</code> containing random variables taken from a uniform distribution in the interval <span>$[-x, x]$</span>, where <code>x = sqrt(24 / sum(dims)) / 2</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.glorot_uniform(2, 3)
0.900868 0.805994 0.057514</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L7-L20">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.glorot_normal"href="#Flux.glorot_normal"><code>Flux.glorot_normal</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">glorot_normal(dims...)</code></pre><p>Return an <code>Array</code> of size <code>dims</code> containing random variables taken from a normal distribution with mean 0 and standard deviation <code>sqrt(2 / sum(dims))</code>.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl">julia> Flux.glorot_normal(3, 2)
-0.223261 0.188052</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L23-L37">source</a></section></article><h2id="Model-Abstraction-1"><aclass="docs-heading-anchor"href="#Model-Abstraction-1">Model Abstraction</a><aclass="docs-heading-anchor-permalink"href="#Model-Abstraction-1"title="Permalink"></a></h2><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.destructure"href="#Flux.destructure"><code>Flux.destructure</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">destructure(m)</code></pre><p>Flatten a model's parameters into a single weight vector.</p><pre><codeclass="language-none">julia> m = Chain(Dense(10, 5, σ), Dense(5, 2), softmax)
...</code></pre><p>The second return value <code>re</code> allows you to reconstruct the original network after making modifications to the weight vector (for example, with a hypernetwork).</p><pre><codeclass="language-none">julia> re(θ .* 2)
Chain(Dense(10, 5, σ), Dense(5, 2), softmax)</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L249-L269">source</a></section></article><h2id="Callback-Helpers-1"><aclass="docs-heading-anchor"href="#Callback-Helpers-1">Callback Helpers</a><aclass="docs-heading-anchor-permalink"href="#Callback-Helpers-1"title="Permalink"></a></h2><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.throttle"href="#Flux.throttle"><code>Flux.throttle</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">throttle(f, timeout; leading=true, trailing=false)</code></pre><p>Return a function that when invoked, will only be triggered at most once during <code>timeout</code> seconds.</p><p>Normally, the throttled function will run as much as it can, without ever going more than once per <code>wait</code> duration; but if you'd like to disable the execution on the leading edge, pass <code>leading=false</code>. To enable execution on the trailing edge, pass <code>trailing=true</code>.</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/utils.jl#L281-L291">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="Flux.Optimise.stop"href="#Flux.Optimise.stop"><code>Flux.Optimise.stop</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia">stop()</code></pre><p>Call <code>Flux.stop()</code> in a callback to indicate when a callback condition is met. This will trigger the train loop to stop and exit.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia">cb = function ()
end</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/FluxML/Flux.jl/blob/87ba651add9ce3851dbcc3c3a989b5f03e898d80/src/optimise/train.jl#L42-L54">source</a></section></article></article><navclass="docs-footer"><aclass="docs-footer-prevpage"href="../ecosystem/">« The Julia Ecosystem</a><aclass="docs-footer-nextpage"href="../performance/">Performance Tips »</a></nav></div><divclass="modal"id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <spanclass="colophon-date"title="Tuesday 19 May 2020 11:45">Tuesday 19 May 2020</span>. Using Julia version 1.3.1.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>