Skip to content

Commit 9f19030

Browse files
committed
[docs] draft data
1 parent 134e240 commit 9f19030

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

docs/tutorial/data.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,77 @@
22
layout: default
33
---
44
# Data: Ins and Outs
5+
6+
Data flows through Caffe as [Blobs](net_layer_blob.html#blob-storage-and-communication).
7+
Data layers load input and save output by converting to and from Blob to other formats.
8+
Common transformations like mean-subtraction and feature-scaling are done by data layer configuration.
9+
New input types are supported by developing a new data layer -- the rest of the Net follows by the modularity of the Caffe layer catalogue.
10+
11+
This data layer definition
12+
13+
layers {
14+
name: "mnist"
15+
# DATA layer loads leveldb or lmdb storage DBs for high-throughput.
16+
type: DATA
17+
# the 1st top is the data itself: the name is only convention
18+
top: "data"
19+
# the 2nd top is the ground truth: the name is only convention
20+
top: "label"
21+
# the DATA layer configuration
22+
data_param {
23+
# path to the DB
24+
source: "examples/mnist/mnist_train_lmdb"
25+
# type of DB: LEVELDB or LMDB (LMDB supports concurrent reads)
26+
backend: LMDB
27+
# batch processing improves efficiency.
28+
batch_size: 64
29+
}
30+
# common data transformations
31+
transform_param {
32+
# feature scaling coefficient: this maps the [0, 255] MNIST data to [0, 1]
33+
scale: 0.00390625
34+
}
35+
}
36+
37+
loads the MNIST digits.
38+
39+
**Tops and Bottoms**: A data layer makes **top** blobs to output data to the model.
40+
It does not have **bottom** blobs since it takes no input.
41+
42+
**Data and Label**: a data layer has at least one top canonically named **data**.
43+
For ground truth a second top can be defined that is canonically named **label**.
44+
Both tops simply produce blobs and there is nothing inherently special about these names.
45+
The (data, label) pairing is a convenience for classification models.
46+
47+
**Transformations**: data preprocessing is parametrized by transformation messages within the data layer definition.
48+
49+
layers {
50+
name: "data"
51+
type: DATA
52+
[...]
53+
transform_param {
54+
scale: 0.1
55+
mean_file_size: mean.binaryproto
56+
# for images in particular horizontal mirroring and random cropping
57+
# can be done as simple data augmentations.
58+
mirror: 1 # 1 = on, 0 = off
59+
# crop a `crop_size` x `crop_size` patch:
60+
# - at random during training
61+
# - from the center during testing
62+
crop_size: 227
63+
}
64+
}
65+
66+
**Prefetching**: for throughput data layers fetch the next batch of data and prepare it in the background while the Net computes the current batch.
67+
68+
**Multiple Inputs**: a Net can have multiple inputs of any number and type. Define as many data layers as needed giving each a unique name and top. Multiple inputs are useful for non-trivial ground truth: one data layer loads the actual data and the other data layer loads the ground truth in lock-step. In this arrangement both data and label can be any 4D array. Further applications of multiple inputs are found in multi-modal and sequence models. In these cases you may need to implement your own data preparation routines or a special data layer.
69+
70+
*Improvements to data processing to add formats, generality, or helper utilities are welcome!*
71+
72+
## Formats
73+
74+
Refer to the layer catalogue of [data layers](layers.html#data-layers) for close-ups on each type of data Caffe understands.
75+
76+
## Deployment Input
77+
78+
For on-the-fly computation deployment Nets define their inputs by `input` fields: these Nets then accept direct assignment of data for online or interactive computation.

docs/tutorial/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and these principles direct the project.
2727
- [Solver](solver.html): the solver coordinates model optimization.
2828
- [Layer Catalogue](layers.html): the layer is the fundamental unit of modeling and computation -- Caffe's catalogue includes layers for state-of-the-art models.
2929
- [Interfaces](interfaces.html): command line, Python, and MATLAB Caffe.
30+
- [Data](data.html): how to caffeinate data for model input.
3031

3132
For a closer look at a few details:
3233

0 commit comments

Comments
 (0)