Error Using Prediction With LSTM

조회 수: 4 (최근 30일)
Uriel Eduardo Carrero Cuadrado
Uriel Eduardo Carrero Cuadrado . 2021년 6월 23일
Hi Everyone!
I trained an LSTM with Keras and I'm importing this network with a .h5 file and it has the next characteristics:
Dimensions for inputs in this network with keras are a 3D matrix composed by (number of samples, time steps, number features per time step), I'm trying the same dimension in MATLAB but I get this error:
Undefined function 'predict' for input arguments of type 'nnet.cnn.layer.Layer'.
This is the code that I'm using for predict:
modelfile = 'Modelos\ControlLSTM_XYZ_1.h5';
net = importKerasLayers(modelfile)
Example=randi([0 10],5,4,24)/10;
In this case 'Example' is a matrix of inputs with random values between 1 and 0, that I'd use for generate a prediction with my neural network, I'd like to know if this format for inputs change in MATLAB or if it still the same, due to it's a network from Keras, also I'd like to know if in my code I'm doing some mistake with LSTM networks because I don't understanf why MATLAB show an error related with convolutional neural networks?.
Thanks for your help.

채택된 답변

Swetha Polemoni
Swetha Polemoni 2021년 7월 5일
편집: Swetha Polemoni 님. 2021년 7월 5일
It is observed that you are calling "predict" on the layerGraph object/layers array. predict is not allowed on layerGraph object/layers array. Before calling predict with layerGraph object, the layerGraph object has to be converted to dagnetwork using assembleNetwork. You can find an eample of this case in the following documentation Assemble Network from Pretrained Keras Layers.
To understand the the difference between LayerGraph and DAGNetwork refer to the following answerwhat is the difference between LayerGraph and DAGNetwork in deep learning?
  댓글 수: 1
Uriel Eduardo Carrero Cuadrado
Uriel Eduardo Carrero Cuadrado 2021년 7월 10일
Yes my problem were related to the layers I already solve the problem but in a different way I was importing my network as layers with the command importKerasLayers() (which not support function predict()) so I imported my network with the comand importKerasNetwork() and I can use predict command with my network now, also the shape of inputs that I use is (24,4) being 24 the numbers of characteristics and 4 the number of time steps.
Thanks for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)




Community Treasure Hunt

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

Start Hunting!

Translated by