我一直在關注jeff heaton在線指南,我來到了這一點,我試圖創建一個簡單的NN,它有三個輸入神經元和一個輸出神經元沒有隱藏三層權重與這三個輸入神經元相關聯。簡單的神經網絡與線性層不會產生預期的輸出
神經網絡從總共6個二進制組合中識別出3個比特的兩個二進制組合。
下面的代碼:
class neural{
double weight1=1.0,weight2=1.0,weight3=1.0;
double learningRate = 0.000001;
public double getOutput(double i1,double i2,double i3,double ideals){
double u = weight1*i1 + weight2*i2 + weight3*i3;
double error = 0.0;
error = ideals -u;
weight1 += error * learningRate * i1;
weight2 += error * learningRate * i2 ;
weight3 += error * learningRate * i3 ;
return u;
}
}
public class pattern{
public static void main(String argz[]){
neural a = new neural();
for(int i = 0; i < 2000; i++){
a.getOutput(0.0, 0.0, 0.0,0.0);
a.getOutput(0.0, 0.0, 1.0,1.0);
a.getOutput(0.0, 1.0, 0.0,1.0);
a.getOutput(0.0, 1.0, 1.0,0.0);
a.getOutput(1.0, 1.0, 0.0,0.0);
a.getOutput(1.0, 1.0, 1.0,1.0);
}
}
}
我嘗試了學習速率低至0.000001通過@Widdershins指出
任何超過0.5是1且低於任何爲0這樣的輸出是000101而不是011001
對於這種情況,您需要一個隱藏層。它看起來非常像XOR問題。一層將無法工作。 – lennon310