batch_size怎么设置?
是不是batch_size越大越好?
首先反对上面的尽可能调大batch size的说法,在现在较前沿的视角来看,这种观点无疑是有些滞后的。
关于这个问题,我们来看下深度学习三巨头之一的LeCun杨乐春同志怎么说(想看结论直接翻到最后):
Training with large minibatches is bad for your health. More importantly, it’s bad for your test error. Friends don‘t let friends use minibatches larger than 32. Let’s face it: the only people have switched to minibatch sizes larger than one since 2012 is because GPUs are inefficient for batch sizes smaller than 32. That’s a terrible reason. It just means our hardware sucks.
翻译过来就是:
使用大的batch size有害模型健康。更重要的是,它对测试集的error不利。一个真正的朋友不会让你使用大于32的batch size。直说了吧:2012年来人们开始转而使用更大batch size的原因只是我们的GPU不够强大,处理小于32的batch size时效率太低。这是个糟糕的理由,只说明了我们的硬件还很辣鸡。
那是什么使得大牛LeCun同志对大于32的batch size如此深恶痛绝而发此论呢?
怎么设置batch_size
细究出处