1

他の多くの人々のニューラルネットワークコードを読んだ後、私は自分のコードに何かが正しくないと確信しています。それは機能し、ネットワークをトレーニングできます。隠れ層で次のパーセプトロンをトレーニングするには、最後のパーセプトロンをトレーニングする必要があります。隠れ層のすべてのユニットを並行してトレーニングできるのではないでしょうか。

隠れ層のエラーを計算するコードは次のとおりです。

    for(int i=n->numOfPerceptronLayers-2;i>=1;i--) { // for all hidden layers
        float sum = 0.0; // <- This here is the problem
        for(int j=0;j<n->perceptronLayers[i].numOfPerceptrons;j++) { // For all the units in the current hidden layer
            for(int k=0;k<n->perceptronLayers[i].perceptrons[j].numOfConnections;k++) { // Loop through the current units connections to the previous layer (output layer)
                sum += n->perceptronLayers[i+1].perceptrons[k].error * n->perceptronLayers[i+1].perceptrons[k].weights[j];
            }
            n->perceptronLayers[i].perceptrons[j].error = n->perceptronLayers[i].perceptrons[j].output * (1.0 - n->perceptronLayers[i].perceptrons[j].output) * sum;
        }
    }

これは次のようになります(ただし、これは機能しません):

for(int i=n->numOfPerceptronLayers-2;i>=1;i--) { // for all hidden layers 
    for(int j=0;j<n->perceptronLayers[i].numOfPerceptrons;j++) { // For all the units in the current hidden layer
        float sum = 0.0;
        for(int k=0;k<n->perceptronLayers[i].perceptrons[j].numOfConnections;k++) { // Loop through the current units connections to the previous layer (output layer)
                sum += n->perceptronLayers[i+1].perceptrons[k].error * n->perceptronLayers[i+1].perceptrons[k].weights[j];
        }
        n->perceptronLayers[i].perceptrons[j].error = n->perceptronLayers[i].perceptrons[j].output * (1.0 - n->perceptronLayers[i].perceptrons[j].output) * sum;
    }
}

単一のパーセプトロンではなく、レイヤー全体に対して合計変数を宣言する必要があるのはなぜですか?

4

2 に答える 2

0

何かが欠けていない限り、最初のコード セグメントは間違っていると思いますが、後者のセグメントは正しいと思います。

最初のコード セグメントでは、レイヤー全体に対して 1 つの「合計」変数を使用すると、後続のパーセプトロンが処理されるたびに誤差が蓄積されます。したがって、パーセプトロン j は常にパーセプトロン j-1 よりも多くの誤差を持ちます。

後者のコードはこの問題を修正しますが、それが機能していないとあなたは言います。最初のコード セグメントは機能しないはずなので、本当の問題はコードの別の場所にあるというのが唯一の妥当な結論です。

余談ですが、各パーセプトロンはエラーのシェアをフォワード接続のみに依存するため、レイヤーのすべてのパーセプトロンを並行してトレーニングできるはずです(標準のフィードフォワード逆伝播)。

于 2011-08-17T00:34:09.860 に答える
0

問題を見つけたようです。基本的に、単一のパーセプトロンをトレーニングする私の TrainPerceptron(Perceptron* p, float error, float moment) 関数には、パーセプトロン構造にエラー プロパティがありましたが、引数を介してパーセプトロンのエラーが与えられました。エラー プロパティを関数に渡していましたが、その引数を削除し、パーセプトロン構造に格納されたエラーを使用しただけで機能したため、何かが混乱していると思います。

于 2011-08-17T01:59:25.173 に答える