机器学习01之基本概念及感知器
来源:互联网 发布:软件开发生命周期模型 编辑:程序博客网 时间:2024/06/05 06:22
转载自: http://www.cnblogs.com/hesi/p/7149678.html
public class perception { public float[] weigth;//权值 public float[][] x;//输入值 public int[] y;//样本的真实类标 public float rate;//学习数率,决定每一次循环训练中所产生的权值变化; public float[] output;//输出的类标 public float b=0;//阈值,也称为偏差 /** * 实例化感知器 * @param x 输入的数据 * @param d 学习速率 */ public perception(float[][] x, float d,int[] y) { super(); this.x = x;//输入数据 this.rate = d;//学习数率 this.y=y;//样本的真实类标 weigth=new float[x[0].length];//初始化权值数组 randomWeigth(x[0].length);//随机给权值赋值 } /** * 给权值进行赋值,初始值为0 * @param n 权值数组的大小 */ public void randomWeigth(int n){ // Random random = new Random(); for(int i=0;i<n;i++){ weigth[i]=0; } } /** * 训练感知器:计算出误差,然后进行权值更新 */ public void train(){ output=new float[x.length]; //获取输出值 for(int i=0;i<x.length;i++){ output[i]=getoutput(x[i]); } //更新 for(int i=0;i<output.length;i++){ float update=rate*(y[i]-output[i]); //更新权重 for(int j=0;j<weigth.length;j++){ weigth[j]=weigth[j]+update*x[i][j]; } //更新偏差 b=b+update; } } //计算输出值 public int getoutput(float[] x){ int output;//输出值 //计算净输入 float z = 0; for(int i=0;i<x.length;i++){ z+=x[i]*weigth[i]; } //激励函数 if(z>=b) output=1; else output=-1; return output; } }
阅读全文
0 0
- 机器学习01之基本概念及感知器
- 机器学习之感知器
- 机器学习之感知器
- 机器学习之感知器学习算法
- 机器学习系列之 感知器模型
- 【机器学习】感知器
- 机器学习之感知机
- 机器学习之感知机
- 机器学习之基本概念
- 机器学习——感知器算法及python实现
- 【机器学习】简单感知器
- 感知器 机器学习算法
- 机器学习之感知机&&python实践
- 机器学习系列之感知机
- 机器学习入门之感知机
- 机器学习基础之----感知机----
- 机器学习之感知机python实现
- 机器学习入门之基本概念
- jstl的c标签应用
- 海量数据处理系列之(一)Java线程池使用
- error in ./src/main.js ✘ http://eslint.org/docs/rules/quotes Strings must use singlequote
- 使用Keras动手实践深度学习(下)
- EditText光标位置的控制或选中某些文本
- 机器学习01之基本概念及感知器
- Oracle 12c ASM专题|Flex磁盘组到底有多Fexible?
- Set、Collection、List、SortedSet、HashSet
- HashMap和LinkedHashMap的区别
- FPGA图像处理系列:图像缩放
- openshift/origin学习记录(3)——添加Registry
- ios brew安装记录
- 嵌入式linux内核组成
- JSP九大内置对象及四个作用域