基于神经网络的模式识别

实验目的理解BP神经网络和离散Hopfield神经网络的结构和原理掌握反向传播学习算法对神经元的训练过程,了解反向传播公式通过构建BP网络和离散Hopfield网络模式识别实例,熟悉前馈网络和反馈网络的原理及结构通过编写源代码理解基于神经网络的模式识别BP神经网络代码#include <iostream>#include <vector>#include...
摘要由CSDN通过智能技术生成

实验目的

  1. 理解BP神经网络和离散Hopfield神经网络的结构和原理
  2. 掌握反向传播学习算法对神经元的训练过程,了解反向传播公式
  3. 通过构建BP网络和离散Hopfield网络模式识别实例,熟悉前馈网络和反馈网络的原理及结构
  4. 通过编写源代码理解基于神经网络的模式识别

BP神经网络代码

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <time.h>
#include <stdlib.h> 
#include <algorithm>

using namespace std;

#define train_cycle 1000	//训练周期为1000 
#define train_step 0.3		//训练步长
#define train_num 10		//训练数字数量
#define table_len 9			//表格长
#define table_wid 7			//表格宽
#define max_lim 0.9			//输出最大临界值	
#define min_lim 0.1			//输出最小临界值
#define input_num 63		//输入层神经元数
#define hidden_num 30		//隐层神经元数
#define output_num 10		//输出层神经元数

struct input_neurons {
	//	double inp;
	double outp;
	double w[hidden_num];
}input_n[input_num];

struct hidden_neurons {
	double inp;
	double outp;
	double w[output_num];
}hidden_n[hidden_num];

struct output_neurons {
	double inp;
	double outp;
}output_n[output_num];

//训练数据
bool trainData[train_num][table_len][table_wid] = {
	0,0,0,0,0,0,0,		//真实数字0
	0,1,1,1,1,1,0,
	0,1,0,0,0,1,0,
	0,1,0,0,0,1,0,
	0,1,0,0,0,1,0,
	0,1,0,0,0,1,0,
	0,1,0,0,0,1,0,
	0,1,1,1,1,1,0,
	0,0,0,0,0,0,0,		//0
	0,0,0,0,0,0,0,		//1
	0,0,0,1,0,0,0,
	0,0,1,1,0,0,0,
	0,0,0,1,0,0,0,
	0,0,0,1,0,0,0,
	0,0,0,1,0,0,0,
	0,0,0,1,0,0,0,
	0,1,1,1,1,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觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值