Caffe : Tutorial : Data: Ins と Outs (翻訳/解説)
翻訳 : (株)クラスキャット セールスインフォメーション
日時 : 04/03/2017
* 本ページは、Caffe の本家サイトの Tutorial – Data: Ins and Outs を翻訳した上で
適宜、補足説明したものです:
http://caffe.berkeleyvision.org/tutorial/data.html
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
データは Caffe を通して Blob として流れます。データ層は、Blob を他のフォーマットへ/から変換することにより入力をロードして出力をセーブします。平均値除去と特徴スケーリングのような一般的な変換はデータ層構成によってなされます。新しい入力タイプは新しいデータ層を開発することによりサポートされます — the rest of the Net follows by the modularity of the Caffe layer catalogue.
このデータ層定義は :
layer {
name: "mnist"
# データ層は高いスループットのために leveldb または lmdb ストレージ DB をロードします。
type: "Data"
# 1番目はデータそれ自身です: 名前は単に慣例によります。
top: "data"
# 2番目は ground truth です: 名前は単に慣例によります。
top: "label"
# データ層構成
data_param {
# DB へのパス
source: "examples/mnist/mnist_train_lmdb"
# type of DB: LEVELDB or LMDB (LMDB supports concurrent reads)
backend: LMDB
# batch processing improves efficiency.
batch_size: 64
}
# common data transformations
transform_param {
# feature scaling coefficient: this maps the [0, 255] MNIST data to [0, 1]
scale: 0.00390625
}
}
MNIST 数字をロードします。
Tops と Bottoms: データ層は、モデルにデータを出力するために top blobs を作成します。入力を取らないので bottom blobs は持ちません。
Data と Label: データ層は規範的に data という名前を持つ少なくとも一つの top を持ちます。ground truth のためには2番目の top が定義されます、これは規範的に label と命名されます。両者の tops は単に blobs を生成してこれらの名前は本質的には特別なものはありません。分類モデルのためには (data, label) ペアは便利です。
変換 (Transformations): データ前処理はデータ層定義内の変換 message でパラメータ化されます。
layer {
name: "data"
type: "Data"
[...]
transform_param {
scale: 0.1
mean_file_size: mean.binaryproto
# for images in particular horizontal mirroring and random cropping
# can be done as simple data augmentations.
mirror: 1 # 1 = on, 0 = off
# crop a `crop_size` x `crop_size` patch:
# - at random during training
# - from the center during testing
crop_size: 227
}
}
Prefetching: スループットのためにNet が現在のバッチを計算している間にデータ層はデータの次のバッチを fetch してバックグラウンドでそれを準備します。
Multiple Inputs: Net は任意の数とタイプの複数の入力を持つことができます。必要なだけデータ層を定義して一意な名前と top を与えます。複数の入力は自明でない ground truth に有用です : 一つのデータ層は実際のデータをロードして他のデータ層は足並みを揃えて ground truth をロードします。このアレンジでデータとラベルは任意の 4D 配列となります。複数入力の更なるアプリケーションはマルチモードとシークエンス・モデルで見つかります。これらのケースでは貴方自身のデータ準備ルーチンか特別なデータ層を実装する必要があるかもしれません。
フォーマット、一般化、あるいはヘルパー・ユティリティを追加するためのデータ処理の改良を歓迎します!
フォーマット
Refer to the layer catalogue of data layers for close-ups on each type of data Caffe understands.
Deployment Input
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.
以上