Having problems with the trainnet function
12 次查看(过去 30 天)
显示 更早的评论
I am trying to fine tune a machine learning model. While using the trainnet function it states "Training stopped: Training loss is NaN" in the command window. The old trainNetwork functions works, which to me makes it weird that trainnet does not. How do I work around this? Possible solutions?


1 个评论
回答(1 个)
Jayanti
2024-10-14
编辑:Jayanti
2024-10-14
Hi Andrew,
I tried to run the code you provided on custom dataset, and it is working fine as you can see in the attached image.

Without actual data, it is difficult to provide a definitive solution upfront. However, the following two options can be explored to address this issue:
- Adjusting learning rate – If learning rate is very high it can cause the model to diverge, leading to “NaN” values. So, try reducing the learning rate.
- Gradient Clipping - Consider adding gradient clipping to prevent exploding gradients.
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!