I have a trained prediction model in keras (with tensorflow backend) using custom layers on Ubuntu 18.04 LTS,
and want to import this model in MATLAB using importKerasNetwork for further prediction (On Windows 10).
So, this is a cross-platform requirement.
when tried to import in MATLAB R2018a (also tried in later versions as well).
model = importKerasNetwork('model_file.h5'); % model_file.h5 is the model saved in keras (with tensorflow backend) using 'save' method
Error using importKerasNetwork (line 86)
Unable to import network because some network layers are not yet supported. To import layers and weights, call importKerasLayers with 'ImportWeights' set to true.
layers = importKerasLayers('model_file.h5', 'ImportWeights' , true);
Warning: Unable to import some Keras layers, because they are not yet supported by the Deep Learning Toolbox. They have been replaced by placeholder layers. To find
these layers, call the function findPlaceholderLayers on the returned object.
> In nnet.internal.cnn.keras.importKerasLayers (line 29)
In importKerasLayers (line 102)
In test_import_keras_model (line 4)
I cannot replace or remove my custom layers, because prediction will not be correct.
I also tried using assembleNetwork but it did'nt work.
Another, last option that I see is trying to train the prediction model using a custom activation function (required for my implementation).
Before, trying this, important question is whether there is any support in MATLAB to import keras models
with custom activation functions?
I request Mathworks, to kindly expedite the process of providing support for importing keras (tensorflow) models with:
A) Custom Layers and/or
B) Custom activation functions