How to save GAN Model after training?

조회 수: 8 (최근 30일)
Suhail Mahmud
Suhail Mahmud 2022년 11월 8일
댓글: Jorge Muñoz 2024년 3월 24일
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