最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

【BP分類】基于鳥群算法優(yōu)化BP神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)數(shù)據(jù)分類附matlab代碼

2022-06-03 00:05 作者:Matlab工程師  | 我要投稿

1 簡介

BSA 算法優(yōu)化 BP 神經(jīng)網(wǎng)絡(luò)的基本思想是: 利 用 BSA 算法的全局搜索能力, 優(yōu)化 BP 神經(jīng)網(wǎng)絡(luò)初始的權(quán)值和閾值, 也就是決策變量, 其中每一組決策變量均包含在鳥群個(gè)體所處的空間位置中. 然后, 通過適應(yīng)度函數(shù)來衡量個(gè)體所處空間位置的優(yōu)劣度, 并利用鳥群覓食過程中的覓食行為、警戒行為和飛行行為等策略不斷更新個(gè)體空間位置, 直至獲取最佳的個(gè)體空間位置, 即獲得待優(yōu)化問題的最佳決策變量

img

BSA-BP 算法預(yù)測 PMV 指標(biāo)主要包括以下幾個(gè)部分: 確定訓(xùn)練樣本數(shù)據(jù)、設(shè)計(jì) BP 神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu)、利用 BSA 算法優(yōu)化 BP 神經(jīng)網(wǎng)絡(luò)初始的權(quán)值和閾值、訓(xùn)練優(yōu)化后的網(wǎng)絡(luò). 具體實(shí)現(xiàn)步驟如下:

步驟 1. 確定訓(xùn)練樣本數(shù)據(jù). 確定所需輸入變量的取值范圍; 然后, 根據(jù) PMV 指標(biāo)的數(shù)學(xué)模型, 利用MATLAB 軟件編輯 PMV 指標(biāo)的計(jì)算程序, 獲取相當(dāng)數(shù)量的樣本數(shù)據(jù); 最后, 經(jīng)過預(yù)處理, 作為 BP 神經(jīng)網(wǎng)絡(luò)的訓(xùn)練樣本和測試樣本數(shù)據(jù).

步驟 2. 設(shè)計(jì) BP 神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu). 依據(jù)標(biāo)準(zhǔn) BP 神經(jīng)網(wǎng)絡(luò)模型以及 PMV 指標(biāo)的數(shù)學(xué)模型, 確定 BP 神經(jīng)網(wǎng)絡(luò)的層數(shù)、每層的神經(jīng)元數(shù), 以及其他參數(shù).

步驟 3. 確定 BSA 算法中各參數(shù). 包括初始化種群規(guī)模 N、搜索空間維數(shù) D、最大迭代次數(shù) T、飛行間隔 FQ、覓食概率 P、常量 C、S、a1、a2、FL 以及隨機(jī)初始化鳥群個(gè)體空間位置 xti.

步驟 4. 計(jì)算 BSA 算法的適應(yīng)度函數(shù)值, 將樣本的均方誤差作為適應(yīng)度函數(shù), 找到最小的適應(yīng)度值, 并保留當(dāng)前最好個(gè)體空間位置. 判斷算法終止條件是否滿足, 若滿足則轉(zhuǎn)至步驟 6, 否則執(zhí)行步驟

5.步驟 5. BSA 算法優(yōu)化 BP 神經(jīng)網(wǎng)絡(luò)初始的權(quán)值和閾值. 依據(jù) BSA 算法的步驟, 不斷迭代進(jìn)行尋優(yōu), 直到迭代停止, 輸出全局最優(yōu)值, 也就是最優(yōu)網(wǎng)絡(luò)初始的權(quán)值和閾值, 并將其賦給 BP 神經(jīng)網(wǎng)絡(luò).

步驟 6. 訓(xùn)練 BSA 算法優(yōu)化后的 BP 神經(jīng)網(wǎng)絡(luò). 網(wǎng)絡(luò)經(jīng)訓(xùn)練結(jié)束后, 將得到最佳的 PMV 指標(biāo)預(yù)測模型.上面所述的實(shí)現(xiàn)步驟可見圖 3

img



2 部分代碼

% ------------------------------------------------------------------------% Bird Swarm Algorithm (BSA) (demo)% This is a simple demo version only implemented the basic idea of BSA for% solving the unconstrained problem, namely Sphere function.%% The details about BSA are illustratred in the following paper.% Xian-Bing Meng, et al (2015): A new bio-inspXred optimisation algorithm:% Bird Swarm Algorithm, Journal of Experimental & Theoretical% Artificial Intelligence, DOI: 10.1080/0952813X.2015.1042530%% The parameters in BSA are presented as follows.% FitFunc ? ?% The objective function% M ? ? ? ? ?% Maxmimal generations (iterations)% pop ? ? ? ?% Population size% dim ? ? ? ?% Dimension% FQ ? ? ? ? % The frequency of birds' flight behaviours% c1 ? ? ? ? % Cognitive accelerated coefficient% c2 ? ? ? ? % Social accelerated coefficient% a1, a2 ? ? % Two paramters which are related to the indirect and direct% ? ? ? ? ? ? ?effect on the birds' vigilance bahaviors.%% Using the default value, BSA can be executed using the following code.% [ bestX, fMin ] = BSA% ------------------------------------------------------------------------% Main programsfunction [ bestX, fMin ,yy] = BSA( FitFunc, M, pop, dim, FQ, c1, c2, a1, a2 )% Display helphelp BSA.m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set the default parameters% set the parameterslb= -100*ones( 1,dim ); ? % Lower boundsub= 100*ones( 1,dim ); ? ?% Upper bounds%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Initializationfor i = 1 : pop ? ?x( i, : ) = lb + (ub - lb) .* rand( 1, dim ); ? ?fit( i ) = FitFunc( x( i, : ) );endpFit = fit; % The individual's best fitness valuepX = x; ? ? % The individual's best position corresponding to the pFit[ fMin, bestIndex ] = min( fit ); ?% fMin denotes the global optimum% bestX denotes the position corresponding to fMinbestX = x( bestIndex, : );%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start the iteration.for iteration = 1 : M ? ?prob = rand( pop, 1 ) .* 0.2 + 0.8;%The probability of foraging for food ? ?if( mod( iteration, FQ ) ~= 0 ) ? ? ? ?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ? ? ? ?% Birds forage for food or keep vigilance ? ? ? ?sumPfit = sum( pFit ); ? ? ? ?meanP = mean( pX ); ? ? ? ?for i = 1 : pop ? ? ? ? ? ?if rand < prob(i) ? ? ? ? ? ? ? ?x( i, : ) = x( i, : ) + c1 * rand.*(bestX - x( i, : ))+ ... ? ? ? ? ? ? ? ? ? ?c2 * rand.*( pX(i,:) - x( i, : ) ); ? ? ? ? ? ?else ? ? ? ? ? ? ? ?person = randiTabu( 1, pop, i, 1 ); ? ? ? ? ? ? ? ?x( i, : ) = x( i, : ) + rand.*(meanP - x( i, : )) * a1 * ... ? ? ? ? ? ? ? ? ? ?exp( -pFit(i)/( sumPfit + realmin) * pop ) + a2 * ... ? ? ? ? ? ? ? ? ? ?( rand*2 - 1) .* ( pX(person,:) - x( i, : ) ) * exp( ... ? ? ? ? ? ? ? ? ? ?-(pFit(person) - pFit(i))/(abs( pFit(person)-pFit(i) )... ? ? ? ? ? ? ? ? ? ?+ realmin) * pFit(person)/(sumPfit + realmin) * pop ); ? ? ? ? ? ?end ? ? ? ? ? ?x( i, : ) = Bounds( x( i, : ), lb, ub ); ? ? ? ? ? ?fit( i ) = FitFunc( x( i, : ) ); ? ? ? ?end ? ? ? ?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ? ?else ? ? ? ?FL = rand( pop, 1 ) .* 0.4 + 0.5; ? ?%The followed coefficient ? ? ? ?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ? ? ? ?% Divide the bird swarm into two parts: producers and scroungers. ? ? ? ?[ans, minIndex ] = min( pFit ); ? ? ? ?[ans, maxIndex ] = max( pFit ); ? ? ? ?choose = 0; ? ? ? ?if ( minIndex < 0.5*pop && maxIndex < 0.5*pop ) ? ? ? ? ? ?choose = 1; ? ? ? ?end ? ? ? ?if ( minIndex > 0.5*pop && maxIndex < 0.5*pop ) ? ? ? ? ? ?choose = 2; ? ? ? ?end ? ? ? ?if ( minIndex < 0.5*pop && maxIndex > 0.5*pop ) ? ? ? ? ? ?choose = 3; ? ? ? ?end ? ? ? ?if ( minIndex > 0.5*pop && maxIndex > 0.5*pop ) ? ? ? ? ? ?choose = 4; ? ? ? ?end ? ? ? ?%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ? ? ? ?if choose < 3 ? ? ? ? ? ?for i = (pop/2+1) : pop ? ? ? ? ? ? ? ?x( i, : ) = x( i, : ) * ( 1 + randn ); ? ? ? ? ? ? ? ?x( i, : ) = Bounds( x( i, : ), lb, ub ); ? ? ? ? ? ? ? ?fit( i ) = FitFunc( x( i, : ) ); ? ? ? ? ? ?end ? ? ? ? ? ?if choose == 1 ? ? ? ? ? ? ? ?x( minIndex,: ) = x( minIndex,: ) * ( 1 + randn ); ? ? ? ? ? ? ? ?x( minIndex, : ) = Bounds( x( minIndex, : ), lb, ub ); ? ? ? ? ? ? ? ?fit( minIndex ) = FitFunc( x( minIndex, : ) ); ? ? ? ? ? ?end ? ? ? ? ? ?for i = 1 : 0.5*pop ? ? ? ? ? ? ? ?if choose == 2 || minIndex ~= i ? ? ? ? ? ? ? ? ? ?person = randi( [(0.5*pop+1), pop ], 1 ); ? ? ? ? ? ? ? ? ? ?x( i, : ) = x( i, : ) + (pX(person, :) - x( i, : )) * FL( i ); ? ? ? ? ? ? ? ? ? ?x( i, : ) = Bounds( x( i, : ), lb, ub ); end% End of the main program%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The following functions are associated with the main program%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This function is the objective function

3 仿真結(jié)果

4 參考文獻(xiàn)

[1]郭彤穎, 陳露. 基于鳥群算法優(yōu)化BP神經(jīng)網(wǎng)絡(luò)的熱舒適度預(yù)測[J]. 計(jì)算機(jī)系統(tǒng)應(yīng)用, 2018, 27(4):5.

博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。

部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。



【BP分類】基于鳥群算法優(yōu)化BP神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)數(shù)據(jù)分類附matlab代碼的評論 (共 條)

分享到微博請遵守國家法律
凤阳县| 屏东市| 阿图什市| 墨竹工卡县| 四会市| 安阳市| 朝阳市| 中牟县| 和林格尔县| 兴国县| 义乌市| 吉首市| 仁化县| 呼玛县| 秭归县| 永清县| 阿坝县| 眉山市| 泸州市| 沐川县| 凤山县| 迁西县| 茶陵县| 凤山市| 西青区| 沈丘县| 玛沁县| 龙井市| 河北省| 文登市| 镇康县| 辉县市| 奈曼旗| 平顶山市| 裕民县| 徐汇区| 赞皇县| 普陀区| 阿图什市| 华坪县| 锦州市|