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

4 次查看(过去 30 天)
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);

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Detect and Diagnose Faults 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by