Using the myNeuralNetworkFunction generated from the Neural Network Toolbox App

22 views (last 30 days)
Hi,
Forgive me if this is a simple problem but I can't seem to use the function generated after training a LSTM network in the app.
Once the app is finished it generates a script with the function, however, when i try to put a new data set into in it ([8xTS] 8 features over TS timesteps) the function rejects it with the error:
Cell contents reference from a non-cell array object.
Error in myNeuralNetworkFunction (line 75)
Xd1{ts} = mapminmax_apply(Xi{1,ts},x1_step1);
Here's the section of the script:
Xd1 = cell(1,3);
for ts=1:2
Xd1{ts} = mapminmax_apply(Xi{1,ts},x1_step1);
end
and the line I'm trying to input is
y = myNeuralNetworkFunction(input,2)
What am I doing wrong here?
Thanks in advance for your help

Answers (1)

Anshika Chaurasia
Anshika Chaurasia on 12 Aug 2020
Hi Damien,
  • When the app is finished it generates a script with the function - myNeuralNetworkFunction(X,Xi,~) where Xi should be cell array.
  • As you mentioned that you are using y = myNeuralNetworkFunction(input,2). Here second argument is not cell array i.e. Xi = 2.
  • Hence provide second argument as cell array to myNeuralNetworkFunction.
%[Y,Xf,Af] = myNeuralNetworkFunction(X,Xi,~) takes these arguments:
%
% X = 1xTS cell, 1 inputs over TS timesteps
% Each X{1,ts} = 2xQ matrix, input #1 at timestep ts.
%
% Xi = 1x2 cell 1, initial 2 input delay states.
% Each Xi{1,ts} = 2xQ matrix, initial states for input #1.
%
% Ai = 2x0 cell 2, initial 2 layer delay states.
% Each Ai{1,ts} = 10xQ matrix, initial states for layer #1.
% Each Ai{2,ts} = 2xQ matrix, initial states for layer #2.
%
% and returns:
% Y = 1xTS cell of 1 outputs over TS timesteps.
% Each Y{1,ts} = 2xQ matrix, output #1 at timestep ts.
%
% Xf = 1x2 cell 1, final 2 input delay states.
% Each Xf{1,ts} = 2xQ matrix, final states for input #1.
%
% Af = 2x0 cell 2, final 0 layer delay states.
% Each Af{1ts} = 10xQ matrix, final states for layer #1.
% Each Af{2ts} = 2xQ matrix, final states for layer #2.
%
% where Q is number of samples (or series) and TS is the number of timesteps.
Refer to link for more understanding of error.

Community Treasure Hunt

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

Start Hunting!