2017-06-16 7 views
0

私は完全にうまくいったバックプロパゲーションモデルを持っていましたが、私はバッチトレーニングを実装したかったのです。 (バックプロパゲーション機能で)バッチ訓練前運動量と(ミニ)バッチトレーニングは互換性がありますか?

コードは、擬似コード:

forevery(connection in this.connections.in){ 
    // Adjust weight 
    var deltaWeight = rate * gradient + momentum * connection.previousDeltaWeight; 
    connection.weight += deltaWeight; 
    connection.previousDeltaWeight = deltaWeight; 
} 

// Adjust bias 
var deltaBias = rate * this.error.responsibility + momentum * this.previousDeltaBias; 
this.bias += deltaBias; 

this.previousDeltabias = deltaBias; 

、新しいコードは次のとおりです。

forevery(connection in this.connections.in){ 
    // Adjust weight 
    var deltaWeight = rate * gradient * this.mask + momentum * connection.previousDeltaWeight; 
    connection.totalDeltaWeight += deltaWeight; 
    if(update){ 
    connection.weight += connection.totalDeltaWeight; 
    connection.previousDeltaWeight = connection.totalDeltaWeight; 
    connection.totalDeltaWeight = 0; 
    } 
} 

// Adjust bias 
var deltaBias = rate * this.error.responsibility + momentum * this.previousDeltaBias; 
this.totalDeltaBias += deltaBias; 
if(update){ 
    this.bias += this.totalDeltaBias; 
    this.previousDeltaBias = this.totalDeltaBias; 
    this.totalDeltaBias = 0; 
} 

だから、バッチサイズが4の場合、バックプロパゲーションは3倍と呼び出されますupdate=falseであり、第4回目はupdate=trueである。バッチトレーニングはうまくいきますが、勢いをつけると(=0.9)すべての値がオーバーフローします。何が問題なの?

答えて

0

ワウ。私は間違った勢いを蓄積していた。私はbatch_size回を間違っていたので、今は一度しか含まれていません。

forevery(connection in this.connections.in){ 
    // Adjust weight 
    var deltaWeight = rate * gradient * this.mask; 
    connection.totalDeltaWeight += deltaWeight; 
    if(update){ 
    connection.totalDeltaWeight += momentum * connection.previousDeltaWeight; 
    connection.weight += connection.totalDeltaWeight; 
    connection.previousDeltaWeight = connection.totalDeltaWeight; 
    connection.totalDeltaWeight = 0; 
    } 
} 

// note: MINI_BATCH SHALL BE OPTIMIZED SOON 

// Adjust bias 
var deltaBias = rate * this.error.responsibility; 
this.totalDeltaBias += deltaBias; 
if(update){ 
    this.totalDeltaBias += momentum * this.previousDeltaBias; 
    this.bias += this.totalDeltaBias; 
    this.previousDeltaBias = this.totalDeltaBias; 
    this.totalDeltaBias = 0; 
} 
関連する問題