Neural Network Error for Number of inputs does not match the net number of inputs

4 views (last 30 days)
Hello. For some reason the number of inputs does not match the net number of inputs. Inputs is a 13x80 array and the labels are a 1x13 so I'm not too sure why this isn't working. Any help would be greatly apprectiated.
data =readtable('EURUSD=X.csv');
[m,n] = size(data);
k = floor(m/20)*20; % gives me exact number of rows of data for 20 days period
data = data(1:k,:); % removes extra unwanted trailing data
Open = data(:,2);
High= data(:,3);
Low = data(:,4);
Close = data(:,5);
G = floor((0:height(data)-1)/20).' + 1;
DataE20 = splitapply(@(Date,Open,High,Low,Close,AdjClose,Volume) {[Open,High,Low,Close].'}, data, G);
inputs = zeros(length(DataE20),80);
%makes each 4x20 arry in DataE20 into a 1x80 array
for k = 1: length(DataE20)
tmp = DataE20{k};
tmp = tmp(:);
inputs(k,:) = tmp;
end
Start = cellfun(@(x)x(1),DataE20);
Finish = cellfun(@(x)x(end),DataE20);
x = length(DataE20)
%Create lables
for y = 1:x
if Finish(y)>Start(y);
Labels(y) = 1;
else
Labels(y) = 0 ;
end
end
for layer1 = 1:15
for layer2 = 1:15
network = patternnet([layer1 layer2]);
network.trainParam.showWindow = false;
trained_net = train(network,inputs',Labels); %network,input,target
op = trained_net(DataE20);
conf = confusion(Labels,op);
if best_conf>conf
best_conf = conf;
best_net = trained_net;
end
end
end
Error:
Error using network/sim (line 270)
Number of inputs does not match net.numInputs.
Error in network/subsref (line 15)
otherwise, v = sim(vin,subs{:});
Error in Project1 (line 62)
op = trained_net(DataE20);

Accepted Answer

KSSV
KSSV on 15 Dec 2022
This line:
op = trained_net(DataE20);
should be:
op = trained_net(inputs');

More Answers (0)

Categories

Find more on Detect and Diagnose Faults in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!