Error for input into Neural Network
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello. I am trying to train a neural network but I am getting an error. My code is:
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);
%Store the data Open,High, Low and Close for every 20 days in the variable
%DataE20
G = floor((0:height(data)-1)/20).' + 1;
DataE20 = splitapply(@(Date,Open,High,Low,Close,AdjClose,Volume) {[Open,High,Low,Close].'}, data, G)
celldisp(DataE20(13))
Start = cellfun(@(x)x(1),DataE20)
Finish = cellfun(@(x)x(end),DataE20)
x = length(DataE20)
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,DataE20,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
best_conf
I get the error:
Error using network/train (line 340)
Number of inputs does not match net.numInputs.
Error in Project1 (line 56)
trained_net = train(network,DataE20,Labels); %network,input,target
How can I fix this? Any help would be greatly appreciated.
2 Commenti
Sudarshan
il 6 Dic 2022
Could you let me know why you are passing DataE20 as a cell array of 4x20 doubles into the input?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!