Insuring reproducibility in training YOLOv2 in the Deep Learning Toolbox

2 次查看(过去 30 天)
I'm using the YOLOv2 network in the Deep Learning Toolbox. We are seeing significant variations in testing results running the same training code more than once.
Is it possible to insure reproducibility in training? If so, what options/flags would need to be set to insure reproducible training?
One option I see already is to set the "Shuffle" option to "none" (its default is "once").
But are there other flags/random seeds that I need to set to insure repeatability?
Thanks!
  2 个评论
Mohammad Sami
Mohammad Sami 2020-4-30
编辑:Mohammad Sami 2020-4-30
You can try using rng with a seed as the first step.
I could not find a direct documentation for the training deep learning models, but i am assuming that this applies to training deep learning models as well.
https://www.mathworks.com/help/matlab/math/generate-random-numbers-that-are-repeatable.html

请先登录,再进行评论。

回答(1 个)

Ryan Comeau
Ryan Comeau 2020-5-10
Hello,
What you are experiencing is very normal for deep learning. The process of network initialization involves assigning initial weights to each of your layers and activation functions. These initial weights can be fixed by fixing the random seed for initialization as mentioned in the comments above. This may not resolve your problem however. The algorithm which minimizes your loss function is called stochastic gradient descent. A stochastic gradient descent is by definition not deterministic, which means there will always be some variance in your results. This should be seen as a good thing however, we don't want to get stuck in a local minima, which is likely to occurr if our algorithm was deterministic.
If you want to see the performance of deep learning being as deterministic as possible, set the mini batch size to 1. This will remove the ability to not get stuck in local minima and you will see a drop in performance.
The shuffle option you are describing is to shuffle the order of data so that your mini-batches do not always have the same data in them.
Lastly, if you do want to have "consistent" training results, simply redefine what consistent means in this case. Run your training 10 times and the results which occurrs the most frequently will be your replicable results.
Hope this helps,
RC

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by