单层神经网络中的matlab语法错误 [英] matlab syntax errors in single layer neural network

查看:92
本文介绍了单层神经网络中的matlab语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须实现一个单层神经网络或感知器,为此,我有2个文件数据集,一个用于输入,一个用于输出,我必须在matlab中执行此操作而不使用神经工具箱.下面给出2个文件.

I have to implement a single layer neural network or perceptron.For this, I have 2 files data sets , one for the input and one for the output.I have to do this in matlab without using neural toolbox.The format of 2 files is given below.

 In:
    0.832 64.643
    0.818 78.843
    1.776 45.049
    0.597 88.302
    1.412 63.458


Out:
0 0 1
0 0 1
0 1 0
0 0 1
0 0 1

目标输出是对于相应输入所属的特定类别为1,对于其余2个输出为" 0.

The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remaining 2 outputs.

我试图这样做,但是它对我不起作用.

I tried to do this, But it is not working for me.

load in.data
load out.data
x = in(:1);
y = in(:2);

learning rate = 0.2;
max_iteration = 50;

function result = calculateOutput(weights,x, y)
s = x*(weights(1) +weight(2) +weight(3));
if s>=0
 result = 1
else:
 result = -1
end
end

Count = length(x);
weights[0] = rand();
weights[1] = rand();
weights[2] = rand();

iter = 0;
do {
  iter++;
  globalerror = 0;
  for(p=0; p<count;p++){
    output = calculateoutput(weights,x[p],y[p]);
    localerror = output[p] - output
    weights[0]+= learningrate *localerror*x[p];
    weights[1]+= learningrate *localerror*y[p];
    weights[2]+= learningrate *localerror;
    globalerror +=(localerror*localerror);
   }
}while(globalerror != 0 && iter <= max_iteration);

此算法的错误在哪里?

我指的是下面链接中给出的示例:-

I am referring the example given in the link below:-

感知器学习算法未收敛到0

推荐答案

以下是我认为有误的列表:

Here's a list of what I see wrong:

深呼吸

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆