91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4.77MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-04
  • 語言: 其他
  • 標簽: C++??

資源簡介

利用BP神經網絡實現f(x)=sin(x)+cos(x)的擬合逼近

資源截圖

代碼片段和文件信息

#include“BP.h“


//
BP::BP()
{
srand(time(NULL));
//BP網絡結構
input_points=1;
output_points=1;
middle_points=yince;
//輸入
for(int?i=0;i {
W_ik[i]=rand()%((unsigned?int)(1/calulate_error))*calulate_error-0.5;
B_ik[i]=rand()%((unsigned?int)(1/calulate_error))*calulate_error-0.5;
}
//輸出
for(int?i=0;i {
W_kj[i]=rand()%((unsigned?int)(1/calulate_error))*calulate_error-0.5;
}
B_kj=rand()%((unsigned?int)(1/calulate_error))*calulate_error-0.5;
//學習步長
StudyStep_j=0.4;
StudyStep_k=0.4;
//
isfound=false;
//
get_jilei_E.open(“./matlab/jilei.txt“);
}
//
void?BP::process(int?counter)
{
double?jilei_E=0;
for(int?i=0;i {
//隨機選取樣本并賦值
int?index=rand()%total_sample;
double?source_X=-pi+2*(i+1)*pi/total_sample;
double?source_goal=sin(source_X)+cos(source_X);
//歸一化處理
X=(pi+source_X)/(2*pi);
double?goal=(sqrt(2)+source_goal)/(2*sqrt(2));
//隱層計算
for(int?j=0;j {
V_ik[j]=W_ik[j]*X-B_ik[j];//隱層第j個節點的輸入
F_ik[j]=1/(1+exp(-V_ik[j]));//隱層第j個節點的輸出
}
//輸出層計算 就一個輸出節點
V_kj=-B_kj;
for(int?j=0;j {
V_kj+=W_kj[j]*F_ik[j];//輸出層節點的輸入
}
F_kj=1/(1+exp(-V_kj));//輸出層節點的輸出
//////////////////////////誤差計算
jilei_E+=0.5*pow(goal-F_kj2);
//輸出層校正誤差
D_kj=(goal-F_kj)*F_kj*(1-F_kj);//輸出神經元的校正誤差
//隱層校正誤差
for(int?j=0;j {
D_ik[j]=D_kj*W_kj[j]*F_ik[j]*(1-F_ik[j]);
}
//對應權值閾值的修改
for(int?j=0;j {
//輸出層
W_kj[j]=W_kj[j]+StudyStep_j*D_kj*F_ik[j];//權值
//隱層
W_ik[j]=W_ik[j]+StudyStep_k*D_ik[j]*X;//權值
B_ik[j]=B_ik[j]-StudyStep_k*D_ik[j];//閾值
}
B_kj=B_kj-StudyStep_j*D_kj;//輸出層閾值
}
jilei_E=jilei_E/total_sample;
get_jilei_E< if(sqrt(jilei_E) {
isfound=true;
}
}
//
void?BP::validation()
{
//檢驗樣本
for(int?i=0;i {
valid[i]=-3*pi/2+2*i*pi/(2*total_sample);
goalout[i]=sin(valid[i])+cos(valid[i]);
}
//帶入驗證
ofstream?nihe;
nihe.open(“nihe.txt“);
for(int?i=0;i {
//樣本賦值
//X=valid[i];
double?source_X;//目標輸入
double?source_goal;//目標輸出結果
double?source_output;//最終輸出結果
source_X=-pi+2*pi*(i+1)/(total_sample);
source_goal=cos(source_X)+sin(source_X);
//歸一化處理
X=(source_X+pi)/(2*pi);
//隱層計算
for(int?j=0;j {
V_ik[j]=W_ik[j]*X-B_ik[j];
F_ik[j]=1/(1+exp(-V_ik[j]));
}
//輸出層計算
V_kj=-B_kj;
for(int?j=0;j {
V_kj+=W_kj[j]*F_ik[j];
}
F_kj=1/(1+exp(-V_kj));
source_output=2*sqrt(2)*F_kj-sqrt(2);
cout< cout< cout< nihe< nihe< }
nihe.close();
}
//
void?BP::get_param()
{
//
cout<<“隱層節點數:“< for(int?i=0;i {
cout<<“從輸入節點到“<<“第“< cout< cout<<“

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-01-13?21:01??FunctionApproximation\
?????目錄???????????0??2014-01-10?09:31??FunctionApproximation\Debug\
?????文件??????102912??2014-01-13?20:52??FunctionApproximation\Debug\FunctionApproximation.exe
?????文件?????1146732??2014-01-13?20:52??FunctionApproximation\Debug\FunctionApproximation.ilk
?????文件?????1035264??2014-01-13?20:52??FunctionApproximation\Debug\FunctionApproximation.pdb
?????目錄???????????0??2014-01-09?20:54??FunctionApproximation\FunctionApproximation\
?????文件????????4435??2014-01-10?10:19??FunctionApproximation\FunctionApproximation\BP.cpp
?????文件????????1320??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\BP.h
?????目錄???????????0??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\
?????文件??????266506??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\BP.obj
?????文件????????2794??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\cl.command.1.tlog
?????文件???????13628??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\CL.read.1.tlog
?????文件????????1606??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\CL.write.1.tlog
?????文件??????????86??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\FunctionApproximation.lastbuildstate
?????文件????????1865??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\FunctionApproximation.log
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link-cvtres.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link-cvtres.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link-rc.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link-rc.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244-cvtres.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244-cvtres.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244-rc.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244-rc.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2244.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364-cvtres.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364-cvtres.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364-rc.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364-rc.write.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364.read.1.tlog
?????文件???????????2??2014-01-13?20:52??FunctionApproximation\FunctionApproximation\Debug\link.2364.write.1.tlog
............此處省略75個文件信息

評論

共有 條評論