日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

BP神经网络matlab代码

發(fā)布時間:2024/8/1 循环神经网络 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BP神经网络matlab代码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 1. BP神經(jīng)網(wǎng)絡(luò)matlab代碼分享

1. BP神經(jīng)網(wǎng)絡(luò)matlab代碼分享

%%隨機權(quán)重→前向計算→誤差→權(quán)重更新,再來一遍→達(dá)到誤差限,停止%% 初始化 clear close all clc%% 讀取數(shù)據(jù) input=rand(2,200); output=input(1,:).*input(2,:);%% 訓(xùn)練集、測試集 input_train = input(:,1:150); output_train =output(1:150); input_test =input(:,151:end); output_test =output(151:end);%% 數(shù)據(jù)歸一化 [inputn,inputps]=mapminmax(input_train,0,1); [outputn,outputps]=mapminmax(output_train); inputn_test=mapminmax('apply',input_test,inputps);%% 構(gòu)建BP神經(jīng)網(wǎng)絡(luò) net=newff(inputn,outputn,8);% 網(wǎng)絡(luò)參數(shù) net.trainParam.epochs=1000; % 訓(xùn)練次數(shù) net.trainParam.lr=0.01; % 學(xué)習(xí)速率 net.trainParam.goal=0.000001; % 訓(xùn)練目標(biāo)最小誤差 % net.dividefcn=''; %% BP神經(jīng)網(wǎng)絡(luò)訓(xùn)練 net=train(net,inputn,outputn);%% BP神經(jīng)網(wǎng)絡(luò)測試 an=sim(net,inputn_test); %用訓(xùn)練好的模型進(jìn)行仿真 test_simu=mapminmax('reverse',an,outputps); % 預(yù)測結(jié)果反歸一化error=test_simu-output_test; %預(yù)測值和真實值的誤差%%真實值與預(yù)測值誤差比較 figure(1) plot(output_test,'bo-') hold on plot(test_simu,'r*-') hold on plot(error,'square','MarkerFaceColor','b') legend('期望值','預(yù)測值','誤差') xlabel('數(shù)據(jù)組數(shù)'),ylabel('值'),title('測試集預(yù)測值和期望值的誤差對比'),set(gca,'fontsize',12) %計算誤差 [~,len]=size(output_test); MAE1=sum(abs(error./output_test))/len; MSE1=error*error'/len; RMSE1=MSE1^(1/2); disp(['-----------------------誤差計算--------------------------']) disp(['平均絕對誤差MAE為:',num2str(MAE1)]) disp(['均方誤差MSE為: ',num2str(MSE1)]) disp(['均方根誤差RMSE為: ',num2str(RMSE1)])

總結(jié)

以上是生活随笔為你收集整理的BP神经网络matlab代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。