Borrar filtros
Borrar filtros

How to save GAN Model after training?

13 visualizaciones (últimos 30 días)
Suhail Mahmud
Suhail Mahmud el 8 de Nov. de 2022
Comentada: Jorge Muñoz el 24 de Mzo. de 2024
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.

Respuesta aceptada

Vignesh Murugavel
Vignesh Murugavel el 11 de Nov. de 2022
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 comentario
Jorge Muñoz
Jorge Muñoz el 24 de Mzo. de 2024
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by