關鍵字:人工智能,神經網絡,感知器模型
Production system
Abstract: Putting forward along with the computing intelligence, artificial neural network has been developing. At present the industry considering the neural network (NN) classified as artificial intelligence (AI) may not appropriate, and classified as computational intelligence (CI) more telling. Evolutionary computation, artificial life, and some issues of the fuzzy logic system, are classified as computational intelligence. Despite the limits of computational intelligence and artificial intelligence is not obvious, however, discuss the difference and relationship is beneficial, logical thinking refers to the process according to the rules of logic reasoning; It will first information into the concept and symbol, and then, according to the symbolic operation logic reasoning according to the serial mode; This process can be written as a serial of instruction, let the computer to perform. However, visual thinking is the distributed storage of information together, the result is suddenly an idea or a solution to the problem. And this paper is devoted to general thoughts about neural network processing, as well as computer science and technology under the junior professional class "artificial intelligence" of the fourth algorithm experiment.
Keywords: Artificial intelligence, neural network, the perceptron model
1,神經網絡的發展
1.1 連接主義觀點核心
智能的本質是連接機制,神經網絡是一個由大量簡單的處理單元組成的高度複雜的大規模非線性自適應系統。
1.2 模擬人腦的智能行爲的四個層面
•物理結構
•計算模擬
•存儲與操作
•訓練
1.3人工神經網絡
神經網絡是一個並行和分佈式的信息處理網絡。它是以處理單元爲節點,用加權有向弧相互連接而成的有向圖。處理單元是對生理神經元的模擬,而有向弧是對軸突-突觸-樹突對的模擬。有向弧的權重表示兩處理單元間相互作用的強弱。它一般由大量神經元組成
•每個神經元只有一個輸出,可以連接到很多其他的神經元
•每個神經元輸入有多個連接通道,每個連接通道對應於一個連接權係數
2.模型的建立
2.1 人工神經網絡模型
2.2 響應函數的基本作用
2.3 感知器模型
感知器是由美國計算機科學家羅森布拉特(F.Roseblatt)於1957年提出的。單層感知器神經元模型圖:
2.4數學模型
3.感知器算法
3.1訓練步驟
1)對於所要解決的問題,確定輸入向量 X,目標向量T,由此確定維數及網絡結構參數,n,m;
2) 參數初始化;
3)設定最大循環次數;
4)計算網絡輸出;
5)檢查輸出矢量Y與目標矢量T是否相同,如果相同,或以達最大循環次數,訓練結束,否則轉入6;
6)學習,並返回4。
3.2網絡訓練
自適應線性元件的網絡訓練過程可以歸納爲以下三個步驟:
1)表達:計算模型的輸出矢量A=W*P十B,以及與期望輸出之間的誤差E=T—A;
2)檢查:將網絡輸出誤差的平方和與期望誤差相比較,如果其值小於期望誤差,或訓練已達到事先設定的最大訓練次數,則停止訓練;
3)學習:採用W—H學習規則計算新的權值和偏差,並返回到1)。
4,問題引入
4.1問題描述
現在來考慮一個較大的多神經元網絡的模式聯想的設計問題。輸入矢量和目標矢量分別爲:
P=
{
{1,-1,2},
{1.5,2,1},
{1.2,3,-1.6},
{-0.3,-0.5,0.9}
};
T=
{
{0.5,1.1,3,-1},
{3,-1.2,0.2,0.1},
{-2.2,1.7,-1.8,-1.0},
{1.4,-0.4,-0.4,0.6}
};
4.2解題思路
由輸入矢量和目標輸出矢量可得:輸入向量個數 r=3,輸出向量個數 s=4,樣本數 q=4。
這個問題的求解同樣可以採用線性方程組求出,即對每一個輸出節點寫出輸入和輸出之間的關係等式。
實際上要求出這16個方程的解是需要花費一定的時間的,甚至是不太容易的。
對於一些實際問題,常常並不需要求出其完美的零誤差時的解。也就是說允許存在一定的誤差。
在這種情況下,採用自適應線性網絡求解就顯示出它的優越性:因爲它可以很快地訓練出滿足一定要求的網絡權值。
5,程序設計
#include<iostream>
#include<ctime>
#include<cmath>
using namespace std;
const int max_learn_length = 100; //最大學習次數
const float study_rate = 0.2; //學習率
const float anticipation_error = 0.01; //期望誤差
const int input = 3; //三項輸入
const int output = 4; //四項輸出
const int sample = 4; //4組樣本
float P[sample][input] = //4組3項的輸入矢量
{
{1,-1,2},
{1.5,2,1},
{1.2,3,-1.6},
{-0.3,-0.5,0.9}
};
float T[sample][output] = //4組4項的期望輸出矢量
{
{0.5,1.1,3,-1},
{3,-1.2,0.2,0.1},
{-2.2,1.7,-1.8,-1.0},
{1.4,-0.4,-0.4,0.6}
};
int main(int argc, char **argv)
{
float precision; //誤差精度變量
float W[input][sample]; //3項4組輸入對應的網絡權值變量
float B[sample]; //4組閾值變量
float A[sample]; //每組實際輸出值
int ii, ij, ik, ic;
srand(time(0)); //初始化隨機函數
for (ii = 0; ii<sample; ii++)
{
B[ii] = 2 * (float)rand() / RAND_MAX - 1; //閾值變量賦隨機值(-1,1)
for (ij = 0; ij<input; ij++) //網絡權值變量賦隨機值
{
W[ij][ii] = 2 * (float)rand() / RAND_MAX - 1;
}
}
precision = FLT_MAX ; //初始化精度值
for (ic = 0; ic < max_learn_length; ic++) //最大學習次數內循環
{
if (precision<anticipation_error) //循環剪枝函數
{
break;
}
precision = 0;
for (ii = 0; ii<sample; ii++) //4組樣本循環疊加誤差精度
{
for (ij = 0; ij<output; ij++) //計算一組中4項實際的輸出
{
A[ij] = 0.0;
for (ik = 0; ik<input; ik++)
{
A[ij] += P[ii][ik] * W[ik][ij];
}
A[ij] += B[ij];
}
for (ij = 0; ij<output; ij++) //通過學習率調整網絡權值和閾值
{
for (ik = 0; ik<input; ik++)
{
W[ik][ij] += study_rate*(T[ii][ij] - A[ij])*P[ii][ik];
}
B[ij] += study_rate*(T[ii][ij] - A[ij]);
}
for (ij = 0; ij<output; ij++) //計算誤差精度
{
precision += pow((T[ii][ij] - A[ij]),2);
}
}
}
cout << "最大學習次數爲:" << max_learn_length << endl;
cout << "完成目標的學習次數爲:" << ic << endl;
cout << endl << "期望誤差爲:" << anticipation_error << endl;
cout << "達成目標學習後的精度爲:" << precision <<endl<< endl;
cout << "學習後的網絡權值爲:" << endl;
for (ii = 0; ii<sample; ii++) //輸出學習後的網絡權值
{
for (ij = 0; ij<input; ij++) //4組樣本每組3個輸入
{
cout << W[ii][ij] << " ";
}
cout << endl;
}
cout <<endl<< "學習後的閾值爲:" << endl;
for (ii = 0; ii<output; ii++) //輸出學習後的閾值:四個樣本輸出
{
cout << B[ii] << " ";
}
cout << endl<<endl;
system("pause");
return 0;
}