bp神经网络实验报告

深 圳 大 学 实 验 报 告 实验课程名称: 人工神经网络技术 实验项目名称: BP 神经网络对蝴蝶花分类 学院: 专业: 软件工程 报告人: 学号: 班级: 同组人: 无 指导教师: 实验时间: 实验报告提交时间: 教务处制一、 实验目的 初步熟悉MATLAB 工作环境,熟悉命令窗口,学会使用帮助窗口查找帮助信息。 二、 实验内容 1、网络设计,包括输入层、隐含层、输出层节点个数的设计。2、算法步骤3、编程,注意原始数据的通用化,数据输入的随机性。4、网络训练,注意训练数据与验证数据分开。5、网络验证6、结果分析,修改隐含层节点个数,修改学习率,分别对结果的影响。 三、实验步骤 直接在Matlab软件中的Editor中运行以下代码:(完善的代码用红色字体表示) % li.m % A BP NN with momentum to solve Fisher s Iris Flower problem % by lixiujuan, Nov 13, 2011 % % the NN architecture % it is a three layers neural network 4-3-3. % % parameter description % h=4 the node numer of layer % i=3 the node numer of hidden layer % j=3 the node numer of output layer % V[h,i] the weights between and hidden layers % W[i,j] the weights between hidden and output layers % Pi[i] the thresholds of hidden layer nodes % Tau[j] the thresholds of output layer nodes % a[h] the values % b[i] the hidden layer node activations % c[j] the output layer node activations % ck[j] the desired output of output layer nodes % d[j] the eror in output layer nodes % e[i] the eror in hidden layer nodes % DeltaW[i,j] the amount of change for the weights W[i,j] % DeltaV[h,i] the amount of change for the weights V[h,i] % DeltaPi[i] the amount of change for the thresholds Pi[i] % DeltaTau[j] the amount of change for the thresholds Tau[j] % Alpha=0.1 the leaning rate % Beta=0.1 the leaning rate % Gamma=0.8 the constant determines effect of past weight changes % Tor=0.001 the torrelance that determines when to stop training % Maxepoch=1000 the max iterate number% % other parameters % Ntrain=115 the number of trainning sets % Ntest=35 the number of test sets % Otrain[115] the output of training sets % Otest[35] the output of test sets % Odesired[150] the desired output of training and test sets % % function description % f(x)=logsig(x) % f(x)=1/(1+exp(-x)) % % data file % file: data.dat % close all; clc; clf; clear all; % parameters for the NN structure h=4; i=3; j=3; Alpha=0.1; Beta=0.1; Gamma=0.85; Tor=0.0005; Maxepoch=2000; Accuracy=0; Ntrain=115; Ntest=35; %assign random values in the range [-1, +1] V=2*(rand(h,i)-0.5); W=2*(rand(i,j)-0.5); Pi=2*(rand(1,i)-0.5); Tau=2*(rand(1,j)-0.5); DeltaWOld(i,j)=0; %set the delat of Wij to 0 DeltaVOld(h,i)=0; %set the delat of Vij to 0 DeltaPiOld(i)=0; %set the delat of Pi to 0 DeltaTauOld(j)=0; %set the delat of Tau to 0 % the learning process Epoch=1; Error=10; % load the training set data and test set data load data.dat Odesired=data(:,2); % get the desired of output of 150 data sets % normalize the data to rang [-1 +1]datanew=data(:,3:6); maxv=max(max(datanew)); minv=min(min(datanew)); datanorm=2*((datanew-minv)/(maxv-minv)-0.5); while Error>Tor Err(Epoch)=0; for k=1:Ntrain % k = the index of tranning set a=datanorm(k,:); % get t

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐