2

よろしくお願いします。ディープ ラーニング ニューラル ネットワークを実装して、多数の変数 (一種の多変量非線形回帰) を予測しようとしています。最初のステップとして、R で Darch パッケージを見て、コード スニペットを調べています。

http://cran.r-project.org/web/packages/darch/darch.pdf

p 10 から次のコードを実行すると、「排他的 OR」でトレーニングしているように見えますが、結果のニューラル ネットワークは関数を学習できないようです。(1,0) パターンまたは (0,1) パターンのいずれかを true として学習しますが、両方を学習することはありません。私の理解では、これらの種類のネットワークは、初心者向けの「排他的または」を含め、ほぼすべての機能を学習できるはずであるということでした。これは、このネットワークが微調整で利用する元の逆伝播作業によって解決されませんでした。私は何かが欠けている可能性があると思うので、何かアドバイスや助けをいただければ幸いです。(エポックを 10,000 まで増やしましたが、役に立ちませんでした。)

# Generating the datasets
inputs <- matrix(c(0,0,0,1,1,0,1,1),ncol=2,byrow=TRUE)
outputs <- matrix(c(0,1,1,0),nrow=4)
# Generating the darch
darch <- newDArch(c(2,4,1),batchSize=2)
# Pre-Train the darch
darch <- preTrainDArch(darch,inputs,maxEpoch=100)
# Prepare the layers for backpropagation training for
# backpropagation training the layer functions must be
# set to the unit functions which calculates the also
# derivatives of the function result.
layers <- getLayers(darch)
for(i in length(layers):1){
    layers[[i]][[2]] <- sigmoidUnitDerivative

}
setLayers(darch) <- layers
rm(layers)
# Setting and running the Fine-Tune function
setFineTuneFunction(darch) <- backpropagation
darch <- fineTuneDArch(darch,inputs,outputs,maxEpoch=100)
# Running the darch
darch <- darch <- getExecuteFunction(darch)(darch,inputs)
outputs <- getExecOutputs(darch)
cat(outputs[[length(outputs)]])
## End(Not run)


#### Example results


> cat(outputs[[length(outputs)]])
0.02520016 0.8923063 0.1264799 0.9803244

## Different run

> cat(outputs[[length(outputs)]])
0.02702418 0.1061477 0.9833059 0.9813462
4

2 に答える 2

2

それだけの価値があるため、次のことがうまくいきました。

# Generating the datasets
inputs <- matrix(c(0,0,0,1,1,0,1,1),ncol=2,byrow=TRUE)
print(inputs)

outputs <- matrix(c(0,1,1,0),nrow=4)
print(outputs)


# Generating the darch
darch <- newDArch(c(2,4,1),batchSize=4,ff=F)

# Pre-Train the darch
darch <- preTrainDArch(darch,inputs,maxEpoch=200,numCD=4)

# Prepare the layers for backpropagation training for
# backpropagation training the layer functions must be
# set to the unit functions which calculates the also
# derivatives of the function result.
layers <- getLayers(darch)
for(i in length(layers):1){
  layers[[i]][[2]] <- sigmoidUnitDerivative
}

setLayers(darch) <- layers
rm(layers)

# Setting and running the Fine-Tune function
setFineTuneFunction(darch) <- rpropagation
darch <- fineTuneDArch(darch,trainData=inputs,targetData=outputs,
                       maxEpoch=200,
                       isBin=T)

# Running the darch
darch <- darch <- getExecuteFunction(darch)(darch,inputs)
outputs2 <- getExecOutputs(darch)
cat(outputs2[[length(outputs2)]])
## End(Not run)

次の結果が得られました

> # Running the darch
> darch <- darch <- getExecuteFunction(darch)(darch,inputs)

> outputs2 <- getExecOutputs(darch)

> cat(outputs2[[length(outputs2)]])
1.213234e-21 1 1 1.213234e-21
> ## End(Not run)
1.213234e-21 1 1 1.213234e-21

そのため、次の変更が行われました。

  • 学習は、古典的な逆伝播から回復力のある逆伝播に変更されました
  • バッチサイズは 4 に設定されました
  • numCD は 4 に設定されました

私は基本的に Voodoo を実行しているため (これをいくつか練習するまで)、エラー率を約 17% 未満に保つことはできないようです。

編集:

だから私は読んでいて、システムのそれぞれの固有の状態が単一の内部ニューロンに関連していると考える傾向があります. 2 ビット ロジックの場合、入力には 4 つの一意の組み合わせがあるため、4 つの一意の入力状態があります。それを処理できるシステムが必要な場合は、4 つの内部ノードが必要です。これは、8 ビット操作の場合、256 個の内部ノードが必要になる可能性があることを意味します。

アタリゲームの人々はモデル適応制御を行っていたので、あるネットワークでシステムの次の状態を予測し、別のネットワークで現在の状態と予想される次の状態を考慮して最適な制御戦略を決定していました。

これを数千回再実行すると、長時間のトレーニング後の出力は約 18% の確率でエラーになりました。私は本当にそれが好きではありませんでした。

考え:

  • 適切なノイズを追加すると、シミュレートされたアニーリングの安定性への影響を回復できますか?
  • 入力にハミング コードのようなものを追加した場合、スペース サイズを交換して安定させることはできますか?
  • 出力が誤って安定するのは、2 つの出力が正確に等しい場合です。その検出をトレーニング アルゴリズムに組み込み、それを使用して一方の「重み」を更新し、他方を更新せずに (分離されたとされる) ニューロンを分離することはできますか?
  • リスト項目
于 2014-12-04T20:42:03.830 に答える
1

example.xorダーチでベースラインを調整して、単純な xor を正しく確実に学習することができました。ベースライン バージョンは次のとおりです。

> tmp<-mclapply(1:50, function(x) example.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 25 
30 20 

調整されたバリアントは次のとおりです。

trainingData <- matrix(
    c(0,0,
      0,1,
      1,0,
      1,1), ncol=2, byrow=T)
trainingTargets <- matrix(c(0,1,1,0),nrow=4)

tuned.xor <- function() {
    darch(trainingData, trainingTargets,
        # These settings are different
        layers=c(2,6,1),
        darch.batchSize=4,
        darch.fineTuneFunction=function(...) rpropagation(..., weightDecay=0.0001),
        # These settings are all as in example.xor
        darch.bootstrap=F,
        darch.learnRateWeights = 1.0,
        darch.learnRateBiases = 1.0,
        darch.isBin=T,
        darch.stopClassErr=0, 
        darch.numEpochs=1000
    )
}

> tmp<-mclapply(1:50, function(x) tuned.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 
50 
于 2016-06-05T23:49:06.573 に答える