rgetNormFactor.rj1mTargetNormFactor.rj1 return mResult void CBpNet::LoadBpNetCString ampstrNetName CFile file iffile.OpenstrNetNameCFile::modeRead0 MessageBoxNULLquot无法打开文件quotquot错误quotMB_OK return else CArchive myarampfileCArchive::load Serializemyar myar.Close file.Close bool CBpNet::SaveBpNetCString ampstrNetName CFile file ifstrNetName.GetLength0 returnfalse iffile.OpenstrNetNameCFile::modeCreateCFile::modeWrite0 MessageBoxNULLquot无法创建文件quotquot错误quotMB_OK returnfalse else CArchive myarampfileCArchive::store Serializemyar myar.Close file.Close returntrue //网络学习 void CBpNet::learn int iSample1 double dblTotal MSG msg ifm_IsStop m_IsStopfalse //数据正规化处理 normalize whiledblErrorgtdblMseampampm_IsStop dblTotal0.0 foriSample1iSampleltmSampleInput.rowsiSample forwardiSample backwardiSample dblTotaldblErr//总误差 ifdblTotal/dblErrorgt1.04//动态改变学习速率 dblLearnRate10.7 dblLearnRate20.7 else dblLearnRate11.05 dblLearnRate21.05 lEpochs dblErrordblTotal ::PeekMessageampmsgNULL00PM_REMOVE ::DispatchMessageampmsg msg.message-1 ::DispatchMessageampmsg//这样可以消除屏闪和假死机 ifdblErrorltdblMse m_isOKtrue else m_isOKfalse void CBpNet::stop m_IsStoptrue double CBpNet::randabdouble a double b //注意如果应用矩阵库头文件matlib.h对rand函数重新定义只产生01 //之间的随机数 returnb-aranda //将数据转化到01区间 void CBpNet::normalize int ij //输入数据范围 mInputNormFactorscopemSampleInput //目标数据范围 mTargetNormFactorscopemSampleTarget fori1iltmSampleInput.rowsi forj1jltmSampleInput.colsj mSampleInput.rijmSampleInput.rij-mInputNormFactor.rj1/mInputNormFactor.rj2-mInputNormFactor.rj1 fori1iltmSampleTarget.rowsi forj1jltmSampleTarget.colsj mSampleTarget.rijmSampleTarget.rij-mTargetNormFactor.rj1/mTargetNormFactor.rj2-mTargetNormFactor.rj1 //前向计算 void CBpNet::forwardint iSample //根据第iSample个样本前向计算 ifiSamplelt1iSamplegtmSampleInput.rows MessageBoxNULLquot无此样本数据:索引出界quotquot无此样本数据:索引出界quotMB_OK return int ij double sum0.0 //输.
上一篇:
Telnet服务器VC2010代码
下一篇:
让我掉下眼泪的