Error for input into Neural Network

3 次查看(过去 30 天)
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 个评论
Sudarshan
Sudarshan 2022-12-6
Could you let me know why you are passing DataE20 as a cell array of 4x20 doubles into the input?
Killian Flynn
Killian Flynn 2022-12-7
编辑:Killian Flynn 2022-12-7
Hello. Originally I thought I could give each 4x20 doubles a label but it seems as though it needs to be 1x80 instead. The idea is to train the AI so that it take the data from every 20 days and uses it to predict whether the next 20 days will be up or down where up is a 1 and down is a 0. That's the general idea. The data is made up of the Open, close low and high which I thought would make the rows and the data for every 20 days to make the colmns. I hope that helps.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by