【问题标题】:Neural Network Toolbox Matlab神经网络工具箱 Matlab
【发布时间】:2020-12-21 06:11:34
【问题描述】:

我尝试在不使用nnstart gui 接口的情况下创建一个神经网络来训练我自己的数据(x_trainy_train)。

clc
clear
close all

num = xlsread('ts1.xlsx','List1');
n = 100;
i = randperm(n);
x = num(i,:);
y = num(i,:);

x_train = x(1:fix(0.8*n),:);
y_train = x(1:fix(0.8*n),:);

x_test = x(fix(0.8*n)+1:end,:);
y_test = y(fix(0.8*n)+1:end,:);
net = feedforwardnet(15,'trainlm');
[net,tr] = train(net,x_train,y_train);

神经网络训练结果:

到目前为止一切正常。

outputs = net(x_test);

但这里我有一些错误:

Error using network/sim (line 270)
Input data sizes do not match net.inputs{1}.size.

Error in network/subsref (line 15)
        otherwise, v = sim(vin,subs{:});

Error in Neural (line 19)
outputs = net(x_test);

有什么建议可以帮助我解决我的问题吗?

【问题讨论】:

  • 欢迎来到 SO。请注意,任何出现在错误之后的代码都与问题无关(从不执行),不应将其包含在此处,因为它只会造成不必要的混乱;与问题无关的代码也是如此(已编辑)。另外,请重读How to ask; quoting: "请勿发布代码、数据、错误消息等的图片。 - 将文本复制或输入到问题中"
  • 感谢评论,我会尽快努力的

标签: matlab neural-network


【解决方案1】:

在第十行,你写了

y_train = x(1:fix(0.8*n),:);

只需将 x 替换为 y。

【讨论】:

    猜你喜欢
    • 2011-07-08
    • 2015-06-03
    • 2013-01-13
    • 2013-09-07
    • 2014-01-02
    • 2014-04-20
    • 2012-04-20
    • 2016-10-17
    • 2015-01-10
    相关资源
    最近更新 更多