MATLAB Answers

Loading a saved deep learning network into matlab

32 views (last 30 days)
I am trying to import my saved vgg19 network into a different matlab script in order to perform image classification.
So I performed transfer learning on the original vgg 19 network using the code of https://nl.mathworks.com/help/deeplearning/examples/transfer-learning-using-alexnet.html. I saved to modified vgg19 network with
save net;
This creates a '.mat' file in the directory that I am currently in. However when I load this file into a new project for instance it import each variable of the network as a seperate variable. When I look what is in the 'net' variable which is a DAGNetwork as expected has 2 properties: layers and connections. But these properties don't include anything while it is expected that they include a 47x1 layer and 46x2 table.
When I look at the size of the DAGNetwork is also shows it is completely empy (0 Bytes) while I expect this to be around 500 MB.
I really don't know what I am doing wrong as I have been looking on the internet for the correct way of importing a saved network into matlab.

  0 Comments

Sign in to comment.

Accepted Answer

lukas mattheuwsen
lukas mattheuwsen on 30 Oct 2019
Apperently it didn't had to do with the way I tried to save and import the network but with the version I used to save it and than load it again. You see, I trained the network on a workstation which has multiple GPUs, more RAM and a more powerful CPU than my personal laptop at work. But as testing the network doesn't really require a powerful PC, I transfered the trained network files to my own laptop to test the network. Training the network was done in Matlab 2019a while I have 2018b on my laptop. This resulted in the network to be empy as I imported it matlab 2018b.
Moral of the story is to not use different versions of matlab in the same project!
But thanks to everyone for their sugestions.

  0 Comments

Sign in to comment.

More Answers (2)

Divya Gaddipati
Divya Gaddipati on 29 Oct 2019
Hi,
Instead of
save net;
try using
save('net.mat', 'net');
and see if that works.

  0 Comments

Sign in to comment.


Steven Lord
Steven Lord on 29 Oct 2019
According to the documentation page for the vgg19 function "This function requires Deep Learning Toolbox™ Model for VGG-19 Network support package." Is this support package installed on the machine where you're trying to load the network? I would have expected you to receive a warning when you tried to load the network onto the machine if you don't, but it's possible to disable that warning even if I don't recommend doing so.

  0 Comments

Sign in to comment.

Sign in to answer this question.