【问题标题】:MATLAB neural networksMATLAB 神经网络
【发布时间】:2011-08-23 07:22:03
【问题描述】:

我正在使用一个简单的 XOR 输入和输出数据集来训练神经网络,然后再尝试更努力的事情,但由于某种原因它不起作用。

有人可以解释一下我做错了什么吗? 这是我的代码:

    %user specified values
hidden_neurons = 3;
epochs = 10000;

t_input = [1 1; 1 0; 0 1; 0 0];
t_output = [1; 0; 0; 1];
te_input = [1 1; 1 0; 0 1; 0 0];

net = newff(t_input, t_output, 1);
net = init(net);
net = train(net, t_input, t_output);
net.trainParam.show = 50;
net.trainParam.lr = 0.25;
net.trainParam.epochs = epochs;
net.trainParam.goal = 1e-5;
net = train(net, t_input, t_output);
out = sim(net, te_input);

这是我的错误信息:

???在 145 处使用 ==> network.train 时出错 目标大小不正确 网络。矩阵必须有 2 列。

==> smallNN 在 11 net = 训练(网络,t_input,t_output);

【问题讨论】:

    标签: matlab neural-network


    【解决方案1】:

    您必须将样本放在列上而不是行上(就像世界上所有的 NN 软件一样),所以在以下位置更改数据集创建行:

    t_input = [1 1; 1 0; 0 1; 0 0]';
    t_output = [1; 0; 0; 1]';
    te_input = [1 1; 1 0; 0 1; 0 0]';
    

    现在可以了。

    【讨论】:

      猜你喜欢
      • 2015-12-03
      • 2014-01-15
      • 2010-11-20
      • 2011-07-31
      • 2014-04-09
      • 2015-07-21
      • 2011-06-02
      • 2012-09-19
      • 1970-01-01
      相关资源
      最近更新 更多