Caffe 需要打乱数据吗? [英] Does Caffe need data to be shuffled?
问题描述
我使用 C++ 将我的图像数据转换为 caffe db 格式(leveldb、lmdb)作为示例我将此代码用于 imagenet.
I convert my image data to caffe db format (leveldb, lmdb) using C++ as example I use this code for imagenet.
是否需要对数据进行混洗,我可以将我所有的正样本写入数据库,然后将所有负样本写入数据库,例如 00000000111111111,还是需要对数据进行混洗并且标签看起来应该像 010101010110101011010?
Is data need to be shuffled, can I write to db all my positives and then all my negatives like 00000000111111111, or data need to be shuffled and labels should look like 010101010110101011010?
caffe 如何从 DB 中采样数据,它使用大小 = batch_size
的所有数据的随机子集是真的吗?
How caffe sample data from DB, is it true that it use random subset of all data with size = batch_size
?
推荐答案
你应该洗牌样本吗? 想想不洗牌的学习过程;caffe 只能看到 0
个样本 - 您希望算法推断出什么?一直简单地预测 0
一切都很酷.如果您在点击第一个 1
之前有足够的 0
,caffe 将非常有信心预测总是 0
.从这一点开始移动模型将非常困难.
另一方面,如果它不断看到 0
和 1
的混合,它会从一开始学习用于分离示例的有意义的特征.
底线:打乱训练样本非常有利,尤其是在使用基于 SGD 的方法时.
Should you shuffle the samples? Think about the learning process if you don't shuffle; caffe sees only 0
samples - what do you expect the algorithm to deduce? simply predict 0
all the time and everything is cool. If you have plenty of 0
before you hit the first 1
caffe will be very confident in predicting always 0
. It will be very difficult to move the model from this point.
On the other hand, if it constantly sees a mix of 0
and 1
it learns from the beginning meaningful features for separating the examples.
Bottom line: it is very advantageous to shuffle the training samples, especially when using SGD-based approaches.
AFAIK,caffe 不会随机采样 batch_size
样本,而是在 batch_size
样本之后顺序遍历输入 DB batch_size
.
AFAIK, caffe does not randomly sample batch_size
samples, but rather goes sequentially over the input DB batch_size
after batch_size
samples.
TL;DR
洗牌.
这篇关于Caffe 需要打乱数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!