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.

采纳的回答

Vignesh Murugavel
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
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 CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by