输入和目标具有不同数量的样本

时间:2019-08-19 13:28:18

标签: matlab neural-network

我在Excel文件中有数据。它由7列和22行组成。四个列输入和三个输出,当我想训练它们时,总是在下面出现这些错误:

Error using network/train (line 340)
Inputs and targets have different numbers of samples.

Error in train_neural_network (line 14)
net = train(net, x, y);

我该怎么办?

我的神经网络代码如下:

clc; close all; clear all;

filename = 'D:\Raneen.xlsx';
sheet = 1;
xlRange = 'A2:D23';
ylRange = 'E2:G23';
x = xlsread(filename,sheet,xlRange);
y = xlsread(filename,sheet,ylRange);

net = newff(minmax(x),[20,1],{'logsig','purelin','trainlm'});
net.trainparam.epochs = 8000;
net.trainparam.goal = 1e-25;
net.trainparam.lr = 0.01;
net = train(net, x, y);

y_net = net(x);

1 个答案:

答案 0 :(得分:0)

不知道为什么会出现问题,但是尝试将X和y拆分,这可能会解决您的问题

x = xlsread(文件名)

y = x [:,5:]

x = x [:,1:4]