build based on aa17017

This commit is contained in:
autodocs 2017-03-01 01:37:12 +00:00
parent 0982686978
commit e57180301d
13 changed files with 42 additions and 13 deletions

View File

@ -150,7 +150,7 @@ Backends
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/apis/backends.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/apis/backends.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -155,7 +155,7 @@ Batching
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/apis/batching.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/apis/batching.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -139,7 +139,7 @@ Storing Models
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/apis/storage.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/apis/storage.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -136,7 +136,7 @@ Contributing &amp; Help
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/contributing.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/contributing.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -139,7 +139,7 @@ Char RNN
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/examples/char-rnn.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/examples/char-rnn.md">
<span class="fa"> <span class="fa">
</span> </span>
@ -216,6 +216,35 @@ sample(model[1:end-1], 100)</code></pre>
<code>sample</code> <code>sample</code>
then produces a string of Shakespeare-like text. This won&#39;t produce great results after only a single epoch (though they will be recognisably different from the untrained model). Going for 30 epochs or so produces good results. then produces a string of Shakespeare-like text. This won&#39;t produce great results after only a single epoch (though they will be recognisably different from the untrained model). Going for 30 epochs or so produces good results.
</p> </p>
<p>
Trained on
<a href="https://gist.githubusercontent.com/MikeInnes/c2d11b57a58d7f2466b8013b88df1f1c/raw/4423f7cb07c71c80bd6458bb94f7bf5338403284/julia.jl">
a dataset from base Julia
</a>
, the network can produce code like:
</p>
<pre><code class="language-julia">function show(io::IO, md::Githompty)
Buffer(jowerTriangular(inals[i], initabs_indices), characters, side, nextfloat(typeof(x)))
isnull(r) &amp;&amp; return
start::I!
for j = 1:length(b,1)
a = s-&gt;cosvect(code)
return
end
indsERenv | maximum(func,lsg))
for i = 1:last(Abjelar) &amp;&amp; fname (=== nothing)
throw(ArgumentError(&quot;read is declave non-fast-a/remaining of not descride method names&quot;))
end
if e.ht === Int
# update file to a stroducative, but is decould.
# xna i -GB =# [unsafe_color &lt;c *has may num 20&lt;11E 16/s
tuple | Expr(:(UnitLowerTriangular(transpose,(repl.ptr)))
dims = pipe_read(s,Int(a)...)
ex,0 + y.uilid_func &amp; find_finwprevend(msg,:2)
ex = stage(c)
# uvvalue begin
end
end</code></pre>
<footer> <footer>
<hr/> <hr/>
<a class="previous" href="logreg.html"> <a class="previous" href="logreg.html">

View File

@ -139,7 +139,7 @@ Logistic Regression
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/examples/logreg.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/examples/logreg.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -147,7 +147,7 @@ Home
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/index.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/index.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -136,7 +136,7 @@ Internals
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/internals.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/internals.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -155,7 +155,7 @@ Model Building Basics
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/models/basics.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/models/basics.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -139,7 +139,7 @@ Debugging
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/models/debugging.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/models/debugging.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -139,7 +139,7 @@ Recurrence
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/models/recurrent.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/models/recurrent.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -155,7 +155,7 @@ Model Templates
</a> </a>
</li> </li>
</ul> </ul>
<a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/2de6b063adbbb3228af6534f321a0c46ff0607f6/docs/src/models/templates.md"> <a class="edit-page" href="https://github.com/MikeInnes/Flux.jl/tree/aa17017acd9ce87de99b81381355b046941f9704/docs/src/models/templates.md">
<span class="fa"> <span class="fa">
</span> </span>

View File

@ -261,7 +261,7 @@ var documenterSearchIndex = {"docs": [
"page": "Char RNN", "page": "Char RNN",
"title": "Char RNN", "title": "Char RNN",
"category": "section", "category": "section",
"text": "This walkthrough will take you through a model like that used in Karpathy's 2015 blog post, which can learn to generate text in the style of Shakespeare (or whatever else you may use as input). shakespeare_input.txt is here.using Flux\nimport StatsBase: wsampleFirstly, we define up front how many steps we want to unroll the RNN, and the number of data points to batch together. Then we create some functions to prepare our data, using Flux's built-in utilities.nunroll = 50\nnbatch = 50\n\ngetseqs(chars, alphabet) = sequences((onehot(Float32, char, alphabet) for char in chars), nunroll)\ngetbatches(chars, alphabet) = batches((getseqs(part, alphabet) for part in chunk(chars, nbatch))...)Because we want the RNN to predict the next letter at each iteration, our target data is simply our input data offset by one. For example, if the input is \"The quick brown fox\", the target will be \"he quick brown fox \". Each letter is one-hot encoded and sequences are batched together to create the training data.input = readstring(\"shakespeare_input.txt\")\nalphabet = unique(input)\nN = length(alphabet)\n\nXs, Ys = getbatches(input, alphabet), getbatches(input[2:end], alphabet)Creating the model and training it is straightforward:model = Chain(\n Input(N),\n LSTM(N, 256),\n LSTM(256, 256),\n Affine(256, N),\n softmax)\n\nm = tf(unroll(model, nunroll))\n\n@time Flux.train!(m, Xs, Ys, η = 0.1, epoch = 1)Finally, we can sample the model. For sampling we remove the softmax from the end of the chain so that we can \"sharpen\" the resulting probabilities.function sample(model, n, temp = 1)\n s = [rand(alphabet)]\n m = tf(unroll(model, 1))\n for i = 1:n\n push!(s, wsample(alphabet, softmax(m(Seq((onehot(Float32, s[end], alphabet),)))[1]./temp)))\n end\n return string(s...)\nend\n\nsample(model[1:end-1], 100)sample then produces a string of Shakespeare-like text. This won't produce great results after only a single epoch (though they will be recognisably different from the untrained model). Going for 30 epochs or so produces good results." "text": "This walkthrough will take you through a model like that used in Karpathy's 2015 blog post, which can learn to generate text in the style of Shakespeare (or whatever else you may use as input). shakespeare_input.txt is here.using Flux\nimport StatsBase: wsampleFirstly, we define up front how many steps we want to unroll the RNN, and the number of data points to batch together. Then we create some functions to prepare our data, using Flux's built-in utilities.nunroll = 50\nnbatch = 50\n\ngetseqs(chars, alphabet) = sequences((onehot(Float32, char, alphabet) for char in chars), nunroll)\ngetbatches(chars, alphabet) = batches((getseqs(part, alphabet) for part in chunk(chars, nbatch))...)Because we want the RNN to predict the next letter at each iteration, our target data is simply our input data offset by one. For example, if the input is \"The quick brown fox\", the target will be \"he quick brown fox \". Each letter is one-hot encoded and sequences are batched together to create the training data.input = readstring(\"shakespeare_input.txt\")\nalphabet = unique(input)\nN = length(alphabet)\n\nXs, Ys = getbatches(input, alphabet), getbatches(input[2:end], alphabet)Creating the model and training it is straightforward:model = Chain(\n Input(N),\n LSTM(N, 256),\n LSTM(256, 256),\n Affine(256, N),\n softmax)\n\nm = tf(unroll(model, nunroll))\n\n@time Flux.train!(m, Xs, Ys, η = 0.1, epoch = 1)Finally, we can sample the model. For sampling we remove the softmax from the end of the chain so that we can \"sharpen\" the resulting probabilities.function sample(model, n, temp = 1)\n s = [rand(alphabet)]\n m = tf(unroll(model, 1))\n for i = 1:n\n push!(s, wsample(alphabet, softmax(m(Seq((onehot(Float32, s[end], alphabet),)))[1]./temp)))\n end\n return string(s...)\nend\n\nsample(model[1:end-1], 100)sample then produces a string of Shakespeare-like text. This won't produce great results after only a single epoch (though they will be recognisably different from the untrained model). Going for 30 epochs or so produces good results.Trained on a dataset from base Julia, the network can produce code like:function show(io::IO, md::Githompty)\n Buffer(jowerTriangular(inals[i], initabs_indices), characters, side, nextfloat(typeof(x)))\n isnull(r) && return\n start::I!\n for j = 1:length(b,1)\n a = s->cosvect(code)\n return\n end\n indsERenv | maximum(func,lsg))\n for i = 1:last(Abjelar) && fname (=== nothing)\n throw(ArgumentError(\"read is declave non-fast-a/remaining of not descride method names\"))\n end\n if e.ht === Int\n # update file to a stroducative, but is decould.\n # xna i -GB =# [unsafe_color <c *has may num 20<11E 16/s\n tuple | Expr(:(UnitLowerTriangular(transpose,(repl.ptr)))\n dims = pipe_read(s,Int(a)...)\n ex,0 + y.uilid_func & find_finwprevend(msg,:2)\n ex = stage(c)\n # uvvalue begin\n end\nend"
}, },
{ {