2

深いQラーニングタスクの安定性を向上させる1つの方法は、ゆっくりと更新され、Q値目標の計算に使用されるネットワークの目標重量のセットを維持することです。その結果、学習手順の異なる時間に、順方向パスにおいて2つの異なる重みの組が使用される。Tensorflowの反復セルの重みにはどうやってアクセスできますか?

sess = tf.Session() 
input = tf.placeholder(tf.float32, shape=[None, 5]) 
weights = tf.Variable(tf.random_normal(shape=[5,4], stddev=0.1) 
bias = tf.Variable(tf.constant(0.1, shape=[4]) 
output = tf.matmul(input, weights) + bias 
target = tf.placeholder(tf.float32, [None, 4]) 
loss = ... 

... 

#Here we explicitly set weights to be the slowly updated target weights 
sess.run(output, feed_dict={input: states, weights: target_weights, bias: target_bias}) 

# Targets for the learning procedure are computed using this output. 

.... 

#Now we run the learning procedure, using the most up to date weights, 
#as well as the previously computed targets 
sess.run(loss, feed_dict={input: states, target: targets}) 

私は、DQNの再発版でこのターゲットネットワーク技術を使用したいのですが、:重みはfeed_dict IEで設定することができtensorflow変数がそうであるように、通常のDQNについては、これは、実装するのは難しいことではありません私は、再発細胞内で使用される体重にアクセスして設定する方法を知らない。具体的には、tf.nn.rnn_cell.BasicLSTMCellを使用していますが、どのタイプの再帰セルでもこれを行う方法を知りたいと思います。

答えて

3

BasicLSTMCellは、その変数を公開APIの一部として公開しません。これらの変数があなたのグラフにどのような名前を持っているか調べて、それらの名前を与えることをお勧めします(これらの名前はチェックポイントにあり、これらの名前を変更するとチェックポイントの互換性が損なわれるため変更できません)。

また、変数を公開するBasicLSTMCellのコピーを作成することもできます。これは最もクリーンなアプローチだと私は思います。

+1

これは、Alexandreに感謝しました。より詳細な情報が必要な人は、再帰セルを 'tf.nn.dynamicrnn()'に渡すと、重みとバイアス変数が作成されます。セッションで 'tf.initialize_all_variables()'を実行した後、 'tf.trainable_variables()'を実行すると見える2つの新しい訓練可能なテンソルがあります。私の場合、彼らは 'RNN/BasicLSTMCell/Linear/Matrix:0'と' RNN/BasicLSTMCell/Linear/Bias:0'という名前でした。 –

関連する問題