From 30110bfc892c393fac8d45e58eaf1a25538185e0 Mon Sep 17 00:00:00 2001 From: autodocs Date: Thu, 28 Sep 2017 10:11:48 +0000 Subject: [PATCH] build based on 8e63ac7 --- latest/contributing.html | 2 +- latest/data/onehot.html | 4 ++-- latest/gpu.html | 25 +++++++++++++++++++++++++ latest/index.html | 2 +- latest/models/basics.html | 2 +- latest/models/layers.html | 4 ++-- latest/models/recurrence.html | 2 +- latest/search.html | 2 +- latest/search_index.js | 16 ++++++++++++++++ latest/training/optimisers.html | 2 +- latest/training/training.html | 2 +- 11 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 latest/gpu.html diff --git a/latest/contributing.html b/latest/contributing.html index 0476ba69..d044ebb0 100644 --- a/latest/contributing.html +++ b/latest/contributing.html @@ -6,4 +6,4 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

Contributing & Help

Contributing & Help

If you need help, please ask on the Julia forum, the slack (channel #machine-learning), or Flux's Gitter.

Right now, the best way to help out is to try out the examples and report any issues or missing features as you find them. The second best way is to help us spread the word, perhaps by starring the repo.

If you're interested in hacking on Flux, most of the code is pretty straightforward. Adding new layer definitions or cost functions is simple using the Flux DSL itself, and things like data utilities and training processes are all plain Julia code.

If you get stuck or need anything, let us know!

+

Contributing & Help

Contributing & Help

If you need help, please ask on the Julia forum, the slack (channel #machine-learning), or Flux's Gitter.

Right now, the best way to help out is to try out the examples and report any issues or missing features as you find them. The second best way is to help us spread the word, perhaps by starring the repo.

If you're interested in hacking on Flux, most of the code is pretty straightforward. Adding new layer definitions or cost functions is simple using the Flux DSL itself, and things like data utilities and training processes are all plain Julia code.

If you get stuck or need anything, let us know!

diff --git a/latest/data/onehot.html b/latest/data/onehot.html index 356b600e..fce487c5 100644 --- a/latest/data/onehot.html +++ b/latest/data/onehot.html @@ -6,7 +6,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

One-Hot Encoding

One-Hot Encoding

It's common to encode categorical variables (like true, false or cat, dog) in "one-of-k" or "one-hot" form. Flux provides the onehot function to make this easy.

julia> using Flux: onehot
+

One-Hot Encoding

One-Hot Encoding

It's common to encode categorical variables (like true, false or cat, dog) in "one-of-k" or "one-hot" form. Flux provides the onehot function to make this easy.

julia> using Flux: onehot
 
 julia> onehot(:b, [:a, :b, :c])
 3-element Flux.OneHotVector:
@@ -37,4 +37,4 @@ julia> onecold(ans, [:a, :b, :c])
 3-element Array{Symbol,1}:
   :b
   :a
-  :b

Note that these operations returned OneHotVector and OneHotMatrix rather than Arrays. OneHotVectors behave like normal vectors but avoid any unnecessary cost compared to using an integer index directly. For example, multiplying a matrix with a one-hot vector simply slices out the relevant row of the matrix under the hood.

+ :b

Note that these operations returned OneHotVector and OneHotMatrix rather than Arrays. OneHotVectors behave like normal vectors but avoid any unnecessary cost compared to using an integer index directly. For example, multiplying a matrix with a one-hot vector simply slices out the relevant row of the matrix under the hood.

diff --git a/latest/gpu.html b/latest/gpu.html new file mode 100644 index 00000000..55bd7113 --- /dev/null +++ b/latest/gpu.html @@ -0,0 +1,25 @@ + +GPU Support · Flux

GPU Support

GPU Support

Support for array operations on other hardware backends, like GPUs, is provided by external packages like CuArrays and CLArrays. Flux doesn't care what array type you use, so we can just plug these in without any other changes.

For example, we can use CuArrays (with the cu array converter) to run our basic example on an NVIDIA GPU.

using CuArrays
+
+W = cu(rand(2, 5))
+b = cu(rand(2))
+
+predict(x) = W*x .+ b
+loss(x, y) = sum((predict(x) .- y).^2)
+
+x, y = cu(rand(5)), cu(rand(2)) # Dummy data
+loss(x, y) # ~ 3

Note that we convert both the parameters (W, b) and the data set (x, y) to cuda arrays. Taking derivatives and training works exactly as before.

If you define a structured model, like a Dense layer or Chain, you just need to convert the internal parameters. Flux provides mapparams, which allows you to alter all parameters of a model at once.

d = Dense(10, 5, σ)
+d = mapparams(cu, d)
+d.W # Tracked CuArray
+d(cu(rand(10))) # CuArray output
+
+m = Chain(Dense(10, 5, σ), Dense(5, 2), softmax)
+m = mapparams(cu, m)
+d(cu(rand(10)))
diff --git a/latest/index.html b/latest/index.html index 047dff31..9ad773f2 100644 --- a/latest/index.html +++ b/latest/index.html @@ -6,5 +6,5 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

Home

Flux: The Julia Machine Learning Library

Flux is a library for machine learning. It comes "batteries-included" with many useful tools built in, but also lets you use the full power of the Julia language where you need it. The whole stack is implemented in clean Julia code (right down to the GPU kernels) and any part can be tweaked to your liking.

Installation

Install Julia 0.6.0 or later, if you haven't already.

Pkg.add("Flux")
+

Home

Flux: The Julia Machine Learning Library

Flux is a library for machine learning. It comes "batteries-included" with many useful tools built in, but also lets you use the full power of the Julia language where you need it. The whole stack is implemented in clean Julia code (right down to the GPU kernels) and any part can be tweaked to your liking.

Installation

Install Julia 0.6.0 or later, if you haven't already.

Pkg.add("Flux")
 Pkg.test("Flux") # Check things installed correctly

Start with the basics. The model zoo is also a good starting point for many common kinds of models.

diff --git a/latest/models/basics.html b/latest/models/basics.html index a54c3b62..1e9ae5a3 100644 --- a/latest/models/basics.html +++ b/latest/models/basics.html @@ -6,7 +6,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

Basics

Model-Building Basics

Taking Gradients

Consider a simple linear regression, which tries to predict an output array y from an input x. (It's a good idea to follow this example in the Julia repl.)

W = rand(2, 5)
+

Basics

Model-Building Basics

Taking Gradients

Consider a simple linear regression, which tries to predict an output array y from an input x. (It's a good idea to follow this example in the Julia repl.)

W = rand(2, 5)
 b = rand(2)
 
 predict(x) = W*x .+ b
diff --git a/latest/models/layers.html b/latest/models/layers.html
index 42f9e75b..1ccd07e3 100644
--- a/latest/models/layers.html
+++ b/latest/models/layers.html
@@ -6,9 +6,9 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 
 ga('create', 'UA-36890222-9', 'auto');
 ga('send', 'pageview');
-

Layer Reference

Model Layers

Flux.ChainType.
Chain(layers...)

Chain multiple layers / functions together, so that they are called in sequence on a given input.

m = Chain(x -> x^2, x -> x+1)
+

Layer Reference

Model Layers

Flux.ChainType.
Chain(layers...)

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

source
Flux.DenseType.
Dense(in::Integer, out::Integer, σ = identity)

Creates a traditional Dense layer with parameters W and b.

y = σ.(W * x .+ 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 in.

source
+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.

source
Flux.DenseType.
Dense(in::Integer, out::Integer, σ = identity)

Creates a traditional Dense layer with parameters W and b.

y = σ.(W * x .+ 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 in.

source
diff --git a/latest/models/recurrence.html b/latest/models/recurrence.html index 5164712c..95fd9577 100644 --- a/latest/models/recurrence.html +++ b/latest/models/recurrence.html @@ -6,7 +6,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

Recurrence

Recurrent Models

Recurrent Cells

In the simple feedforward case, our model m is a simple function from various inputs xᵢ to predictions yᵢ. (For example, each x might be an MNIST digit and each y a digit label.) Each prediction is completely independent of any others, and using the same x will always produce the same y.

y₁ = f(x₁)
+

Recurrence

Recurrent Models

Recurrent Cells

In the simple feedforward case, our model m is a simple function from various inputs xᵢ to predictions yᵢ. (For example, each x might be an MNIST digit and each y a digit label.) Each prediction is completely independent of any others, and using the same x will always produce the same y.

y₁ = f(x₁)
 y₂ = f(x₂)
 y₃ = f(x₃)
 # ...

Recurrent networks introduce a hidden state that gets carried over each time we run the model. The model now takes the old h as an input, and produces a new h as output, each time we run it.

h = # ... initial state ...
diff --git a/latest/search.html b/latest/search.html
index 86fc913d..d94fbbc3 100644
--- a/latest/search.html
+++ b/latest/search.html
@@ -6,4 +6,4 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 
 ga('create', 'UA-36890222-9', 'auto');
 ga('send', 'pageview');
-

Search

Search

Number of results: loading...

    +

    Search

    Search

    Number of results: loading...

      diff --git a/latest/search_index.js b/latest/search_index.js index de222b6b..98f41091 100644 --- a/latest/search_index.js +++ b/latest/search_index.js @@ -216,6 +216,22 @@ var documenterSearchIndex = {"docs": [ "text": "onehotbatch creates a batch (matrix) of one-hot vectors, and argmax treats matrices as batches.julia> using Flux: onehotbatch\n\njulia> onehotbatch([:b, :a, :b], [:a, :b, :c])\n3×3 Flux.OneHotMatrix:\n false true false\n true false true\n false false false\n\njulia> onecold(ans, [:a, :b, :c])\n3-element Array{Symbol,1}:\n :b\n :a\n :bNote that these operations returned OneHotVector and OneHotMatrix rather than Arrays. OneHotVectors behave like normal vectors but avoid any unnecessary cost compared to using an integer index directly. For example, multiplying a matrix with a one-hot vector simply slices out the relevant row of the matrix under the hood." }, +{ + "location": "gpu.html#", + "page": "GPU Support", + "title": "GPU Support", + "category": "page", + "text": "" +}, + +{ + "location": "gpu.html#GPU-Support-1", + "page": "GPU Support", + "title": "GPU Support", + "category": "section", + "text": "Support for array operations on other hardware backends, like GPUs, is provided by external packages like CuArrays and CLArrays. Flux doesn't care what array type you use, so we can just plug these in without any other changes.For example, we can use CuArrays (with the cu array converter) to run our basic example on an NVIDIA GPU.using CuArrays\n\nW = cu(rand(2, 5))\nb = cu(rand(2))\n\npredict(x) = W*x .+ b\nloss(x, y) = sum((predict(x) .- y).^2)\n\nx, y = cu(rand(5)), cu(rand(2)) # Dummy data\nloss(x, y) # ~ 3Note that we convert both the parameters (W, b) and the data set (x, y) to cuda arrays. Taking derivatives and training works exactly as before.If you define a structured model, like a Dense layer or Chain, you just need to convert the internal parameters. Flux provides mapparams, which allows you to alter all parameters of a model at once.d = Dense(10, 5, σ)\nd = mapparams(cu, d)\nd.W # Tracked CuArray\nd(cu(rand(10))) # CuArray output\n\nm = Chain(Dense(10, 5, σ), Dense(5, 2), softmax)\nm = mapparams(cu, m)\nd(cu(rand(10)))" +}, + { "location": "contributing.html#", "page": "Contributing & Help", diff --git a/latest/training/optimisers.html b/latest/training/optimisers.html index 01d10bd0..926ca1f6 100644 --- a/latest/training/optimisers.html +++ b/latest/training/optimisers.html @@ -6,7 +6,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-36890222-9', 'auto'); ga('send', 'pageview'); -

      Optimisers

      Optimisers

      Consider a simple linear regression. We create some dummy data, calculate a loss, and backpropagate to calculate gradients for the parameters W and b.

      W = param(rand(2, 5))
      +

      Optimisers

      Optimisers

      Consider a simple linear regression. We create some dummy data, calculate a loss, and backpropagate to calculate gradients for the parameters W and b.

      W = param(rand(2, 5))
       b = param(rand(2))
       
       predict(x) = W*x .+ b
      diff --git a/latest/training/training.html b/latest/training/training.html
      index be42fbc5..d06fc322 100644
      --- a/latest/training/training.html
      +++ b/latest/training/training.html
      @@ -6,7 +6,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
       
       ga('create', 'UA-36890222-9', 'auto');
       ga('send', 'pageview');
      -

      Training

      Training

      To actually train a model we need three things:

      • A model loss function, that evaluates how well a model is doing given some input data.

      • A collection of data points that will be provided to the loss function.

      • An optimiser that will update the model parameters appropriately.

      With these we can call Flux.train!:

      Flux.train!(modelLoss, data, opt)

      There are plenty of examples in the model zoo.

      Loss Functions

      The loss that we defined in basics is completely valid for training. We can also define a loss in terms of some model:

      m = Chain(
      +

      Training

      Training

      To actually train a model we need three things:

      • A model loss function, that evaluates how well a model is doing given some input data.

      • A collection of data points that will be provided to the loss function.

      • An optimiser that will update the model parameters appropriately.

      With these we can call Flux.train!:

      Flux.train!(modelLoss, data, opt)

      There are plenty of examples in the model zoo.

      Loss Functions

      The loss that we defined in basics is completely valid for training. We can also define a loss in terms of some model:

      m = Chain(
         Dense(784, 32, σ),
         Dense(32, 10), softmax)