From 4d3cd105ec39298470ee1bdb37433d61b08c949d Mon Sep 17 00:00:00 2001
From: autodocs
Date: Tue, 21 Feb 2017 21:43:19 +0000
Subject: [PATCH] build based on c05ef62
---
latest/apis/backends.html | 2 +-
latest/apis/batching.html | 57 +++++++++++++++++++++++++++++++-----
latest/contributing.html | 2 +-
latest/examples/logreg.html | 2 +-
latest/index.html | 2 +-
latest/internals.html | 2 +-
latest/models/basics.html | 2 +-
latest/models/debugging.html | 2 +-
latest/models/recurrent.html | 2 +-
latest/models/templates.html | 2 +-
latest/search_index.js | 2 +-
11 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/latest/apis/backends.html b/latest/apis/backends.html
index 3167c5d9..dece983e 100644
--- a/latest/apis/backends.html
+++ b/latest/apis/backends.html
@@ -140,7 +140,7 @@ Backends
-
+
diff --git a/latest/apis/batching.html b/latest/apis/batching.html
index 9d985349..711162b9 100644
--- a/latest/apis/batching.html
+++ b/latest/apis/batching.html
@@ -145,7 +145,7 @@ Batching
-
+
@@ -298,17 +298,12 @@ Right now, the
-Code can be written in a batch-agnostic way or be generic across batching setups. Code works with a single data point, and batching happens independently.
+Code can be written in a batch-agnostic way or be generic across batching strategies.
-Automatic batching can be done with correctness assured, reducing programmer errors when manipulating dimensions.
-
-
-
-
-Optimisations, like switching batch dimensions, can be expressed by the programmer with compiler support; fewer code changes are required and optimisations are guaranteed not to break the model.
+Batching and optimisations, like switching batch dimensions, can be expressed by the programmer with compiler support; fewer code changes are required and optimisations are guaranteed not to break the model.
@@ -317,6 +312,52 @@ This also opens the door for more automatic optimisations, e.g. having the compi
+
+Here's a more detailed illustration of how it might look for code to be "generic across batching". Take for example a weight matrix
+W
+ times a vector
+x
+, as used in a logistic regression or a simple neural network:
+
+ W * x => y
+(10×28) * (28) => (10)
+
+If we want to work with a batch of 50
+x
+s, one option is to stack the data into a matrix of size
+28 × 50
+.
+
+ W * x => y
+(10×28) * (28×50) => (10×50)
+
+This works, but we may find that it's slow or doesn't fit well with the rest of the model, which batches on the first dimension. For that reason we may instead want to put the data in a
+50 × 28
+ matrix and alter the code as follows:
+
+ x * W' => y
+(50×28) * (28×10) => (50×10)
+
+to make the shapes work out. This code change is not ideal; in more complex cases it can become fiddly and error-prone, and it means that the code is less reusable, tied to a particular implementation strategy.
+
+
+There's an alternative. We keep the same code, but represent the batched
+x
+s as either a
+Batch{Vector,1}
+ or a
+Batch{Vector,2}
+, depending on how the data is stacked. Then we can simply overload
+*
+ as follows:
+
+*(W::Matrix, x::Batch{Vector,1}) = x * W'
+*(W::Matrix, x::Batch{Vector,2}) = W * x
+
+This means that we can always write
+W*x
+, and the code is reusable in a larger network regardless of the overall batching approach. Moreover, Julia's type system ensures there's no runtime cost to doing this, and we can compile the code appropriately for backends like TensorFlow as well.
+
diff --git a/latest/contributing.html b/latest/contributing.html
index 1425d58c..e6fd4848 100644
--- a/latest/contributing.html
+++ b/latest/contributing.html
@@ -126,7 +126,7 @@ Contributing & Help
-
+
diff --git a/latest/examples/logreg.html b/latest/examples/logreg.html
index 328d7113..ff26556e 100644
--- a/latest/examples/logreg.html
+++ b/latest/examples/logreg.html
@@ -129,7 +129,7 @@ Logistic Regression
-
+
diff --git a/latest/index.html b/latest/index.html
index d2e06e06..ade7156f 100644
--- a/latest/index.html
+++ b/latest/index.html
@@ -132,7 +132,7 @@ Home
-
+
diff --git a/latest/internals.html b/latest/internals.html
index 06274d45..3a55975f 100644
--- a/latest/internals.html
+++ b/latest/internals.html
@@ -126,7 +126,7 @@ Internals
-
+
diff --git a/latest/models/basics.html b/latest/models/basics.html
index fd65a02a..9ed2829b 100644
--- a/latest/models/basics.html
+++ b/latest/models/basics.html
@@ -145,7 +145,7 @@ Model Building Basics
-
+
diff --git a/latest/models/debugging.html b/latest/models/debugging.html
index 11b1419d..71c1cd4f 100644
--- a/latest/models/debugging.html
+++ b/latest/models/debugging.html
@@ -129,7 +129,7 @@ Debugging
-
+
diff --git a/latest/models/recurrent.html b/latest/models/recurrent.html
index 4d0610e1..b079c899 100644
--- a/latest/models/recurrent.html
+++ b/latest/models/recurrent.html
@@ -129,7 +129,7 @@ Recurrence
-
+
diff --git a/latest/models/templates.html b/latest/models/templates.html
index 32235ca9..42eb8d7e 100644
--- a/latest/models/templates.html
+++ b/latest/models/templates.html
@@ -145,7 +145,7 @@ Model Templates
-
+
diff --git a/latest/search_index.js b/latest/search_index.js
index c38c1e6d..1749db76 100644
--- a/latest/search_index.js
+++ b/latest/search_index.js
@@ -173,7 +173,7 @@ var documenterSearchIndex = {"docs": [
"page": "Batching",
"title": "Future Work",
"category": "section",
- "text": "The design of batching is still a fairly early work in progress, though it's used in a few places in the system. For example, all Flux models expect to be given Batch objects which are unwrapped into raw arrays for the computation. Models will convert their arguments if necessary, so it's convenient to call a model with a single data point like f([1,2,3]).Right now, the Batch or Seq types always stack along the left-most dimension. In future, this will be customisable, and Flux will provide implementations of common functions that are generic across the batch dimension. This brings the following benefits:Code can be written in a batch-agnostic way or be generic across batching setups. Code works with a single data point, and batching happens independently.\nAutomatic batching can be done with correctness assured, reducing programmer errors when manipulating dimensions.\nOptimisations, like switching batch dimensions, can be expressed by the programmer with compiler support; fewer code changes are required and optimisations are guaranteed not to break the model.\nThis also opens the door for more automatic optimisations, e.g. having the compiler explore the search base of possible batching combinations."
+ "text": "The design of batching is still a fairly early work in progress, though it's used in a few places in the system. For example, all Flux models expect to be given Batch objects which are unwrapped into raw arrays for the computation. Models will convert their arguments if necessary, so it's convenient to call a model with a single data point like f([1,2,3]).Right now, the Batch or Seq types always stack along the left-most dimension. In future, this will be customisable, and Flux will provide implementations of common functions that are generic across the batch dimension. This brings the following benefits:Code can be written in a batch-agnostic way or be generic across batching strategies.\nBatching and optimisations, like switching batch dimensions, can be expressed by the programmer with compiler support; fewer code changes are required and optimisations are guaranteed not to break the model.\nThis also opens the door for more automatic optimisations, e.g. having the compiler explore the search base of possible batching combinations.Here's a more detailed illustration of how it might look for code to be \"generic across batching\". Take for example a weight matrix W times a vector x, as used in a logistic regression or a simple neural network: W * x => y\n(10×28) * (28) => (10)If we want to work with a batch of 50 xs, one option is to stack the data into a matrix of size 28 × 50. W * x => y\n(10×28) * (28×50) => (10×50)This works, but we may find that it's slow or doesn't fit well with the rest of the model, which batches on the first dimension. For that reason we may instead want to put the data in a 50 × 28 matrix and alter the code as follows: x * W' => y\n(50×28) * (28×10) => (50×10)to make the shapes work out. This code change is not ideal; in more complex cases it can become fiddly and error-prone, and it means that the code is less reusable, tied to a particular implementation strategy.There's an alternative. We keep the same code, but represent the batched xs as either a Batch{Vector,1} or a Batch{Vector,2}, depending on how the data is stacked. Then we can simply overload * as follows:*(W::Matrix, x::Batch{Vector,1}) = x * W'\n*(W::Matrix, x::Batch{Vector,2}) = W * xThis means that we can always write W*x, and the code is reusable in a larger network regardless of the overall batching approach. Moreover, Julia's type system ensures there's no runtime cost to doing this, and we can compile the code appropriately for backends like TensorFlow as well."
},
{