MATLAB Answers

MM
0

What to set 'ClassNames' to when using importKerasNetwork() to import network and weights for a regression model?

Asked by MM
on 19 Dec 2018
Latest activity Commented on by Yousaf Rahman on 3 Apr 2019
Hi,
I have trained a regression model in Keras/Tensorflow and exported the network achitecure and weights to .json and .h5 files. I would like to import my regression model to Matlab (R2018a) and looks like importKerasNetwork() does just that. However, it keeps throwing the following error: "Reference to non-existent field 'class_name'." I don't pass any 'Classes' (R2018b) or 'ClassNames' (R2018a) becasue I'm doing regression not classification. This is the how I call the function:
net = importKerasNetwork('model_architecture.json','WeightFile','my_model_weights.h5', 'OutputLayerType','regression');
The documentation (R2018b as well as R2018a) doesn't state what to pass in 'Classes' when you are dealing with a regression problem. I tried passing an empty array but got the same error. Any ideas how to solve this problem?
Thanks!

  0 Comments

Sign in to comment.

Products


Release

R2018a

2 Answers

Answer by Don Mathis on 20 Dec 2018
 Accepted Answer

There were a few updates to that support package after the initial release. Try downloading it and installing it again through the Add-Ons icon in MATLAB. Also if you can upload your model files here I can take a look.

  12 Comments

I am having the same issue, I am using the latest version of the importer (downloaded 4/2/2019), but I am using MATLAB 2017b. I had trouble installing the importer in 2018b, and have a Mathworks Support case ongoing for that.

Sign in to comment.



Hi,
I have the same problem with importing
net = importKerasNetwork(modelfile,'OutputLayerType','regression')
Error using importKerasNetwork (line 77)
Reference to non-existent field 'class_name'
I am using R2017b and just installed the add on for Keras. Could you please let me know where I can find the update which might resolve this problem.
Thanks

  1 Comment

Click on the little drop-down arrow on the Add-Ons icon --> Check for updates --> Add-on fetaures. This usually worked for me.

Sign in to comment.