gpt4 book ai didi

performance - 为深度学习选择小批量大小

转载 作者:行者123 更新时间:2023-12-03 12:39:53 24 4
gpt4 key购买 nike

在 Ilya Sutskever 的博客文章中,A brief overview of Deep Learning ,他描述了选择正确的 minibatch 大小以有效训练深度神经网络的重要性。他给出的建议是“使用在您的机器上高效运行的较小的 minibatch”。请参阅下面的完整报价。

我看过其他知名深度学习研究人员的类似陈述,但我仍然不清楚如何找到正确的 minibatch 大小。看到更大的 minibatch 可以允许更大的学习率,似乎需要大量的实验来确定某个 minibatch 大小是否会在训练速度方面产生更好的性能。

我有一个带有 4gb RAM 的 GPU,并使用 Caffe 和 Keras 库。考虑到每个观察值都有一定的内存占用M 在这种情况下,选择一个好的小批量大小的实用启发式是什么? ?

Minibatches: Use minibatches. Modern computers cannot be efficient if you process one training case at a time. It is vastly more efficient to train the network on minibatches of 128 examples, because doing so will result in massively greater throughput. It would actually be nice to use minibatches of size 1, and they would probably result in improved performance and lower overfitting; but the benefit of doing so is outweighed the massive computational gains provided by minibatches. But don’t use very large minibatches because they tend to work less well and overfit more. So the practical recommendation is: use the smaller minibatch that runs efficiently on your machine.

最佳答案

当我们训练网络时,当我们计算前向传播时,我们必须保留所有后向传播的中间激活输出。除了其他内存限制(将权重存储在 GPU 上等)之外,您只需要计算在前向传递中存储所有相关激活输出将花费多少内存。因此请注意,如果您的网络很深,您可能需要较小的批量,因为您可能没有足够的内存。

选择小批量大小是内存限制和性能/准确性的混合(通常使用交叉验证进行评估)。

我个人猜测时间/手动计算我的前向/后向传递将使用多少 GPU 内存并尝试一些值。例如,如果我能容纳的最大数量大约为 128,我可能会使用 32、64、96 等进行交叉验证,只是为了彻底看看我是否可以获得更好的性能。这通常用于更深的网络,它将插入我的 GPU 内存(我也只有 4 GB 卡,无法访问怪物 NVIDIA 卡)。

我认为人们倾向于更加重视网络架构、交易的优化技术/技巧、数据预处理。

关于performance - 为深度学习选择小批量大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34572186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com