⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 machine learning - c++的bp算法源程序.htm

📁 一个BP算法的C++实现
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                        m,FILE* fp)<BR>{<BR>for (int 
                        j=0;j&lt;HN;j++)<BR>&nbsp;for (int 
                        i=0;i&lt;IN;i++)<BR>//cout&lt;&lt;"第"&lt; 
                        fprintf(fp,"第%d个样本时的输出层至隐层的权值为:%f\n",m,V[j][i]<BR>);<BR>W[j][i]+=beta*e_err[j]*P[i];//隐层至输入层的权值调整<BR>}<BR>sita[j]+=beta*e_err[j];<BR>}<BR>return 
                        1;<BR>}//子程序Delta_H_I()结束
                        <P>/////////////////////////////////<BR>//N个样本的全局误差计算子程序////<BR>/////////////////////////////////<BR>double 
                        Err_Sum()<BR>{<BR>double total_err=0;<BR>for (int 
                        m=0;m&lt;N;m++)<BR>&nbsp;total_err+=err_m[m];//每个样本的均方误差加起来就成了全局误差<BR>}<BR>return 
                        1;<BR>}//子程序Err_sum()结束
                        <P>/**********************/<BR>/**程序入口,即主程序**/<BR>/**********************/<BR>main()<BR>{<BR>FILE 
                        *fp;<BR>double sum_err;<BR>int study;//训练次数
                        <P>if 
                        ((fp=fopen("bp.txt","a+"))==NULL)<BR>{<BR>printf("不能创建bp.txt文件!\n");<BR>exit(1);<BR>}<BR>cout&lt;&lt;"请输入输出层到隐含层学习效率: 
                        alpha=\n";<BR>cin&gt;&gt;alpha;
                        <P>cout&lt;&lt;"请输入隐含层到输入层学习效率: 
                        beta=\n";<BR>cin&gt;&gt;beta;
                        <P>int study=0; //学习次数<BR>double Pre_error ; 
                        //预定误差<BR>cout&lt;&lt;"请输入预定误差: Pre_error= 
                        \n";<BR>cin&gt;&gt;Pre_error;
                        <P>int 
                        Pre_times;<BR>cout&lt;&lt;"请输入预定最大学习次数:Pre_times=\n";<BR>cin&gt;&gt;Pre_times;
                        <P>cout&lt;&lt;"请输入学习样本数据\n";<BR>{<BR>for (int 
                        m=0;m&lt;N;m++)<BR>&nbsp;cout&lt;&lt;"请输入第"&lt;&lt;m+1&lt;&lt;"组学习样本"&lt;&lt;endl;<BR>&nbsp; 
                        for (int i=0;i&lt;IN;i++)<BR>&nbsp; 
                        &nbsp;cin&gt;&gt;Study_Data[m]-&gt;input[i];<BR>}<BR>{<BR>for 
                        (int 
                        m=0;m&lt;N;m++)<BR>cout&lt;&lt;"请输入第"&lt;&lt;m+1&lt;&lt;"组教师样本"&lt;&lt;endl;<BR>&nbsp;for 
                        (int 
                        k=0;k&lt;ON;k++)<BR>cin&gt;&gt;Study_Data[m]-&gt;teach[k];<BR>}
                        <P>initial(); //隐层、输出层权、阈值初始化 (1)<BR>do<BR>{<BR>++study; 
                        ///???<BR>for (int m=0;m&lt;N;m++)<BR>{<BR>input_P(m); 
                        //输入第m个学习样本 (2)<BR>input_T(m);//输入第m个样本的教师信号 
                        (3)<BR>H_I_O(); //第m个学习样本隐层各单元输入、输出值 (4)<BR>O_I_O(); 
                        //第m个学习样本输出层各单元输入、输出值 (5)<BR>Err_O_H(m); 
                        //第m个学习样本输出层至隐层一般化误差 (6)<BR>Err_H_I(); 
                        //第m个学习样本隐层至输入层一般化误差 (7)<BR>Delta_O_H(m,fp); 
                        //第m个学习样本输出层至隐层权阈值调整、修改 (8)<BR>Delta_H_I(m,fp); 
                        //第m个学习样本隐层至输入层权阈值调整、修改 (9)<BR>} //全部样本训练完毕
                        <P>sum_err=Err_Sum(); //全部样本全局误差计算 
                        (10)<BR>{<BR>cout&lt;&lt;"第"&lt;&lt;study&lt;&lt;"次学习的均方误差为"&lt;&lt;sum_err&lt;&lt;endl;<BR>fprintf(fp,"第%d次学习的均方误差为:%f\n",study,sum_err);<BR>}
                        <P>while (sum_err &gt; Pre_error) &nbsp; 
                        &nbsp;//or(study<BR>{ //N个样本全局误差小于预定误差否? 小于则退出 
                        (11)<BR>cout&lt;&lt;"网络已经学习了"&lt;&lt;study&lt;&lt;"次,学习的均方误差为"&lt;&lt;sum_err&lt;&lt;endl;<BR>fprintf(fp,"网络已经学习了%d次,现在的全局误差为:%f\n",study,total_err);<BR>fclose(fp);<BR>}<BR>char 
                        s;<BR>cout&lt;&lt;"请随便输入一个字符,按回车退出程序!\n";<BR>cin&gt;&gt;s;<BR>return 
                        1;<BR>}
                        <P><BR></P></FONT></TD></TR></TBODY></TABLE>
                  <TABLE style="TABLE-LAYOUT: fixed" cellSpacing=0 cellPadding=0 
                  width="100%">
                    <TBODY>
                    <TR>
                      <TD 
                      style="LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word; 130: "><BR><BR><IMG 
                        height=3 
                        src="Machine Learning - C++的BP算法源程序.files/none.gif" 
                        width=1><BR><IMG height=12 
                        src="Machine Learning - C++的BP算法源程序.files/signature.gif"><BR><IMG 
                        height=5 
                        src="Machine Learning - C++的BP算法源程序.files/none.gif" 
                        width=1><BR>新的一天需要太阳来开启!新的感觉需要热情来浇灌!新的智慧需要执着来积淀!</TD></TR></TBODY></TABLE></FONT><BR></TD>
                <TD width=16></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=bottomline vAlign=bottom bgColor=#ffffff>
            <HR width="100%" color=#000000 SIZE=1>

            <TABLE cellSpacing=0 cellPadding=0 width="100%">
              <TBODY>
              <TR>
                <TD vAlign=bottom><FONT color=#000000>  <IMG height=15 
                  alt=发贴时间 
                  src="Machine Learning - C++的BP算法源程序.files/posttime.gif" 
                  width=16 align=absMiddle>2004/05/17 10:52am <IMG height=15 
                  alt="此 IP 为代理服务器" 
                  src="Machine Learning - C++的BP算法源程序.files/ip.gif" width=13 
                  align=absMiddle>IP: 已设置保密</FONT></TD>
                <TD vAlign=bottom align=right width=110 nowarp></TD></FORM>
                <TD vAlign=bottom align=right 
        width=4></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    <TD width=1 bgColor=#000000 height=24></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center bgColor=#000000>
  <TBODY>
  <TR>
    <TD height=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=2 cellPadding=0 width="95%" align=center>
  <TBODY>
  <TR bgColor=#ccccff height=4></TR>
  <TR>
    <TD><FONT color=#333333>&nbsp;<FONT 
  color=#333333>该主题只有一页</FONT></FONT></TD></TR></TBODY></TABLE><BR>
<FORM name=FORM action=post.cgi?action=reply&amp;forum=20&amp;topic=75 
method=post encType=multipart/form-data><INPUT type=hidden value=addreply 
name=action> <INPUT type=hidden value=20 name=forum> <INPUT type=hidden value=75 
name=topic> 
<TABLE cellSpacing=1 cellPadding=5 width="95%" align=center bgColor=#000000>
  <TBODY>
  <TR>
    <TD width=220 bgColor=#ccccff><FONT color=#333333><B>快速回复主题:</B></FONT></TD>
    <TD width=500 bgColor=#ccccff><FONT color=#333333>C++的BP算法源程序</FONT></TD></TR>
  <TR>
    <TD bgColor=#ccccff><FONT color=#333333><B>输入用户名和密码:</B></FONT></TD>
    <TD bgColor=#ccccff><FONT color=#333333><B>用户名</B>: <INPUT 
      onmouseover=this.focus() onfocus=this.select() value=客人 name=membername> 
      <SPAN style="CURSOR: hand" 
      onclick="javascript:location.href='register.cgi?forum=20'">没有注册?</SPAN> <B>密码:</B> 
      <INPUT onmouseover=this.focus() onfocus=this.select() type=password 
      name=password> <A style="CURSOR: help" 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/profile.cgi?action=lostpass">忘记密码?</A></FONT></TD></TR>
  <TR>
    <TD bgColor=#ccccff><B>上传附件或图片</B> (最大容量 <B>500</B>KB)</TD>
    <TD bgColor=#ccccff colSpan=2><INPUT type=file size=45 
      name=addme>  <SELECT><OPTION value=# selected>支持类型:</OPTION><OPTION 
        value=#>----------</OPTION><OPTION>gif</OPTION><OPTION>jpg</OPTION><OPTION>bmp</OPTION><OPTION>zip</OPTION><OPTION>swf</OPTION><OPTION>doc</OPTION><OPTION>txt</OPTION></SELECT></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#eeeeee><FONT color=#333333><B>选项</B> 
      <BR><BR><INPUT type=checkbox CHECKED value=yes name=uselbcode>使用 LB5000 
      标签?<BR><INPUT type=checkbox CHECKED value=yes 
      name=inshowsignature>显示您的签名?<BR><INPUT type=checkbox value=yes 
      name=notify>有回复时使用邮件通知您?<BR><INPUT type=checkbox CHECKED value=yes 
      name=inshowemoticons>使用表情字符转换?<BR></FONT></TD>
    <TD width=* bgColor=#eeeeee><TEXTAREA onkeydown=ctlent() name=inpost rows=8 cols=75></TEXTAREA><BR><INPUT onclick="return clckcntr();" type=submit value="发 表 回 复" name=Submit> <INPUT onclick=gopreview() type=button value="预 览 内 容" name=Button> <INPUT type=reset value="清 除" name=Clear>  [使用 
      Ctrl+Enter 直接提交贴子] </TD></TR></TBODY></TABLE></FORM>
<FORM name=preview action=preview.cgi method=post target=preview_page><INPUT 
type=hidden name=body><INPUT type=hidden value=20 name=forum></FORM>
<SCRIPT>function gopreview(){document.preview.body.value=document.FORM.inpost.value;var popupWin = window.open('preview.cgi', 'preview_page', 'scrollbars=yes,width=500,height=300');document.preview.submit()}</SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center>
  <TBODY>
  <TR>
    <TD>&nbsp;<A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/topic.cgi?forum=20&amp;topic=75&amp;show=50#top"><IMG 
      height=15 src="Machine Learning - C++的BP算法源程序.files/gotop.gif" width=15 
      align=absMiddle border=0>顶端</A> <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/fav.cgi?action=add&amp;forum=20&amp;topic=75"><IMG 
      height=15 src="Machine Learning - C++的BP算法源程序.files/addfavorite.gif" 
      width=18 align=absMiddle border=0>加到"个人收藏夹"</A></TD>
    <TD noWrap align=right><FONT color=#333333><B>主题管理</B>: <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=abslocktop&amp;forum=20&amp;topic=75">总固顶</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=absunlocktop&amp;forum=20&amp;topic=75">取消总固顶</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=locktop&amp;forum=20&amp;topic=75">固顶</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=unlocktop&amp;forum=20&amp;topic=75">取消固顶</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/jinghua.cgi?action=add&amp;forum=20&amp;topic=75">精华</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/jinghua.cgi?action=del&amp;forum=20&amp;topic=75">取消精华</A> 
      |<BR><A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=puttop&amp;forum=20&amp;topic=75">提升</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=lock&amp;forum=20&amp;topic=75">锁定</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/postings.cgi?action=unlock&amp;forum=20&amp;topic=75">解锁</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/recyclebin.cgi?action=add&amp;forum=20&amp;topic=75">回收</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/recyclebin.cgi?action=del&amp;forum=20&amp;topic=75">复原</A> 
      | <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/delpost.cgi?action=delete&amp;forum=20&amp;topic=75">删除</A> 
      | <SPAN style="CURSOR: hand" onclick=javascript:DelReply();>删除回复</SPAN> | 
      <A 
      href="http://ir.hit.edu.cn/cgi-bin/newbbs/delpost.cgi?action=movetopic&amp;forum=20&amp;topic=75">移动</A> 
      | </FONT></TD></TR></TBODY></TABLE>
<P>
<P>
<FORM name=DReply action=delpost.cgi method=post><INPUT type=hidden value=20 
name=forum> <INPUT type=hidden value=75 name=topic> <INPUT type=hidden 
value=directdel name=action> <INPUT type=hidden name=postno></FORM>
<CENTER>
<HR width=380 SIZE=1>

<TABLE cellSpacing=0 cellPadding=0 width="80%" align=center>
  <TBODY>
  <TR>
    <TD align=middle><FONT color=#333333>&copy; 中文版权所有: <A 
      href="http://ir.hit.edu.cn/">哈尔滨工业大学信息检索实验室</A>  版本: <A 
      title=按此可以下载最新版本的雷傲超级论坛 
      href="http://www.cgier.com/cgi-bin/lbdown.cgi">LB5000XP v1201</A><BR><FONT 
      color=#000000>程序版权所有: <A href="http://www.cgier.com/" target=_blank>CGI 
      编程者之家</A>    程序编制: <A href="mailto:htc@263.net">山鹰(糊)</A>、 <A 
      href="mailto:info@cgier.net">花无缺</A></FONT><BR><IMG height=3 
      src="Machine Learning - C++的BP算法源程序.files/none.gif" 
      width=0><BR>本论坛言论纯属发表者个人意见,与<FONT color=#5577aa><B> 哈尔滨工业大学信息检索实验室论坛 
      </B></FONT>立场无关<BR></FONT></TD></TR></TBODY></TABLE></CENTER>
<CENTER><FONT>程序占用 CPU 时间:0.44 usr + 0.01 sys</FONT></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -