Commit ab0048cc authored by Yuxin Wu's avatar Yuxin Wu

Add architure figure

parent edbcf18a
......@@ -18,14 +18,14 @@ As creating a neural network for digit classification seems to be a bit outdated
- Callbacks
+ write your own callback to export predicted images after each epoch
## DataFlow
### DataFlow
The basic idea is to gather a huge amount of images, resizing them to the same size and extract
the luminance channel after converting from RGB to Lab. For demonstration purposes, we will split
the dataflow definition into separate steps, though it might more efficient to combine some steps.
### Reading data
#### Reading data
The first node in the dataflow is the image reader. You can implement the reader however you want, but there are some existing ones we can use, e.g.:
- use the lmdb files you probably already have for the Caffe framework
......@@ -62,7 +62,7 @@ for dp in ds.get_data():
This kind of iteration is used behind the scenes to feed data for training.
### Manipulate incoming data
#### Manipulate incoming data
Now, training a ConvNet which is not fully convolutional requires images of known shape, but our
directory may contain images of different sizes. Let us add this to the dataflow:
......@@ -141,7 +141,7 @@ datapoint 1<2 with 2 components consists of
Well, this is probably not the most efficient way to encode this process. But it clearly demonstrates how much flexibility the `dataflow` gives.
You can easily insert you own functions, and utilize the pre-defined modules at the same time.
## Network
### Network
If you are surprised how far we already are, you will enjoy how easy it is to define a network model. The most simple model is probably:
......@@ -159,7 +159,7 @@ The framework expects:
- a computation graph containing the actual network layers in `_build_graph`
- In single-cost optimization problem, a member `self.cost` representing the loss function we would like to minimize.
### Define inputs
#### Define inputs
Our dataflow produces data which looks like `[(32, 256, 256), (32, 256, 256, 3)]`.
The first entry is the luminance channel as input and the latter is the original RGB image with all three channels. So we will write
......@@ -188,7 +188,7 @@ class Model(ModelDesc):
```
### Define Architecture
#### Define Architecture
So all we need to do is to define a network layout
```math
f\colon \mathbb{R}^{b \times 256 \times 256} \to \mathbb{R}^{b \times 256 \times 256 \times 3}
......@@ -260,7 +260,7 @@ The remaining part is a boring L2-loss function given by:
self.cost = tf.nn.l2_loss(prediction - rgb, name="L2 loss")
```
### Pimp the TensorBoard output
#### Pimp the TensorBoard output
It is a good idea to track the progress of your training session using TensorBoard.
TensorPack provides several functions to simplify the output of summaries and visualization of intermediate states.
......@@ -275,7 +275,7 @@ tf.summary.image('colorized', prediction, max_outputs=10)
add a plot of the moving average of the cost tensor, and add some intermediate results to the tab of "images" inside TensorBoard. The summary is written after each epoch.
Note that you can certainly use `tf.summary.scalar(self.cost)`, but then you'll only see a single cost value (rather than moving average) which is much less informative.
## Training
### Training
Let's summarize: we have a model and data.
The missing piece which stitches these parts together is the training protocol.
......@@ -314,7 +314,7 @@ If you have 42 images in your directory, then this value would be 42.
Satisfied with this answer, the alert reader went out of the room.
But he will miss the most interesting part: the callback section. We will cover this in the next section.
## Callbacks
### Callbacks
Until this point, we spoke about all necessary parts of deep learning pipelines which are common for GANs, image-recognition and embedding learning.
But sometimes you want to add your own code to do something extra. We will now add a functionality which will export some entries of the tensor `prediction`.
......
Welcome to tensorpack!
======================================
tensorpack is in early development.
All tutorials are drafts for now. You can get an idea from them, but the details
might not be correct.
.. toctree::
:maxdepth: 3
tutorial/index
casestudies/index
modules/index
Indices and tables
------------------
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. casestudies/index
### Write an image augmentor
### Write an Image Augmentor
The first thing to note: __you never have to write an augmentor__.
An augmentor is a part of the DataFlow, so you can always
......
## Write a layer
## Write a Layer
The first thing to note: __you never have to write a layer__.
Tensorpack layers are nothing but wrappers of symbolic functions.
......
......@@ -5,28 +5,21 @@ Tutorials
A High Level Glance
====================
* :doc:`dataflow` is a set of extensible tools to help you define your input data with ease and speed.
.. image:: https://user-images.githubusercontent.com/1381301/29099965-58ad3c00-7c5d-11e7-9c42-bf6f20ca694f.png
It provides a uniform interface so that data processing modules can be chained together.
It allows you to load and process your data in pure Python and accelerate it by prefetching.
See also :doc:`input-source` and :doc:`efficient-dataflow` for more details about the efficiency of data
processing.
* You can use any TF-based symbolic function library to define a model in tensorpack.
And ``ModelDesc`` is an interface to connect symbolic graph to tensorpack trainers.
:doc:`graph` and :doc:`symbolic` introduces where and how you define the graph for tensorpack trainers to use,
and how you can benefit from the small symbolic function library in tensorpack.
* DataFlow is a library to load data efficiently in Python.
Apart from DataFlow, native TF operators can be used for data loading as well.
They will eventually be wrapped under the same interface and go through prefetching.
Both DataFlow and models can be used outside tensorpack, as just a data processing library and a symbolic
function library. Tensopack trainers integrate these two components and add more convenient features.
* You can use any TF-based symbolic function library to define a model, including
a small set of models within tensorpack. ``ModelDesc`` is an interface to connect symbolic graph to tensorpack trainers.
* tensorpack :doc:`trainer` manages the training loops for you, so you will not have to worry about
details such as multi-GPU training. At the same time, it keeps the power of customization
through callbacks.
* tensorpack trainers manage the training loops for you. At the same time, you own the power of customization
through callbacks. They also include data parallel logic for multi-GPU or distributed training.
* Callbacks are like ``tf.train.SessionRunHook``, or plugins, or extensions. During training,
everything you want to do other than the main iterations can be defined through callbacks.
See :doc:`callback` for some examples what you can do.
everything you want to do other than the main iterations can be defined through callbacks and easily reused.
User Tutorials
========================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment