How to use double precision in deep learning toolbox?
7 次查看(过去 30 天)
显示 更早的评论
It seems like deep learning toolbox has defalut set single precision. I want double precision in my neural network, how to achieve this? Please Help!
2 个评论
Matt J
2023-11-12
Are you saying you want to train in double precision, or just do inference in double precision?
回答(1 个)
Angelo Yeo
2023-11-14
I understand that you want to use trainNetwork and trainnet to train and predict in double precision This is currently not possible in MATLAB R2023b. Internally, 'trainnet' defaults to single precision and hence cannot be used in this case. This functionality is something the developers are actively working on for a future release.
A workaround is to use a custom training loop. You can refer the following example for a general reference -
1. Once the learnable network parameters are initialized, they must be converted to type double by using 'dlupdate'
net = dlupdate(@double, net);
2. Ensure data is double precision. This can be set using the 'OutputCast' of 'minibatchqueue' to 'double'. Note that this parameter is read-only. It cannot be modified after construction of 'minibatchqueue'.
Please also note that it is not possible to train in double precision if you are using DAGNetwork or SeriesNetwork.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!