How to save GAN Model after training?
8 ビュー (過去 30 日間)
古いコメントを表示
I am using the GAN example live script to train the generator and discrimnator for a synthetic data generator. However, after training the generator and discrimantor (netD, netG) i save the workspace for using the models for later use. Although after reloading the .mat file, i was not able to generate images as it started from begining. Is there any specific way of saving those GAN models in matlab for later use? Thanks.
0 件のコメント
採用された回答
Vignesh Murugavel
2022 年 11 月 11 日
Hi Suhail,
If you want to save your trained GAN network model , you need to use save('path_to_file', 'variable').
Example:
save('C:\Temp\trainedModel_netG.mat','netG');
In this case netG is the name of the network and this trained network will be saved under the given file name “trainedModel_netG.mat”
The next time you want to use the saved pre-trained network you just need to call load('path_to_file').
Example:
load('C:\Temp\trained_netG.mat');
Hope this helps!
1 件のコメント
Jorge Muñoz
2024 年 3 月 24 日
Hello, it seems that the issue mentioned by Suhail is not solely about saving the workspace and reloading it. I'm experiencing something similar to the problem described. When I train the flower image generation example, everything seems to go well as long as the GPU memory keeps the parameters loaded. If I save the complete training workspace using the "save" command (for example, GANWorkspacefile.mat, which also includes netG), then clear the GPU memory (reset), and subsequently reload the previous workspace, the images generated with "predict" end up blurry, like the ones generated at the beginning of training. The same happens if I transfer the saved workspace and load it on another machine with the same version of MATLAB. It seems that something is missing when loading the workspace variables that prevents generating the images in the same way as they are generated just at the end of training.
その他の回答 (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!