Error using importKerasLayers() for Squeezenet using ".json" file.

3 views (last 30 days)
Hello,
I am trying to use the new Neural Network Toolbox function named "importKerasLayers" to import Squeezenet model. But it gives me below error:
*Error using importKerasLayers
Invalid layer name 'fire2/squeeze1x1'. Layer names must not contain the character '/'.*
Please, let me know about it.
I have also tried importing ".h5" file for Squeezenet. But it gives me below error:
*Error using importKerasLayers
Unable to import layers from file 'squeezenet_weights.h5' because it contains no 'model_config' attribute.*
Can you provide a ".json" or ".h5" file for Squeezenet which supports MATLAB.
Looking forward to solve this problem as soon as possible.
Thank you.

Accepted Answer

Mickaël Tits
Mickaël Tits on 14 Nov 2017
Hi,
I had the same problem, so I modified a python script to change layer names (tu use "_" instead of "/"). You can find the corrected model here : https://github.com/titsitits/Squeezenet-Matlab-Keras You can use this line of code to import it :
squeezenet = importKerasNetwork('squeezenet.json','WeightFile','squeezenet.h5','OutputLayerType','classification');
Best regards, Mickaël Tits
  3 Comments
Mickaël Tits
Mickaël Tits on 19 Nov 2017
Hello,
It is actually the version v1.1, which apparently has similar results than v1.0, with much less computations: https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1
I don't have the v1.0 version unfortunately. If you really need the version 1.0, you can try to modify the python script and use the weights of the v1.0.
Regards, Mickaël Tits
Marco Francini
Marco Francini on 30 Nov 2017
Hello, it is working also for me.
Now that I uploaded the Squeezenet to Matlab I used it with transfer learning techninque so it can handle just 3 classes. It is working fine.
Now that I have my network trained, how can I export it to .h5 and .json file? I see that an "exportKerasNetwork" function does not exists...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!