完全に答えはmrry
です。
実際に私はこの問題の別の解決策を掲載します。
tf.gather()
の代わりにtf.dynamic_partition()
を使用して、警告を排除することができます。
のコード例は以下の通りです:
# Create the cells for the RNN network
lstm = tf.nn.rnn_cell.BasicLSTMCell(128)
# Get the output and state from dynamic rnn
output, state = tf.nn.dynamic_rnn(lstm, sequence, dtype=tf.float32, sequence_length = seqlen)
# Convert output to a tessor and reshape it
outputs = tf.reshape(tf.pack(output), [-1, lstm.output_size])
# Set partions to 2
num_partitions = 2
# The partitions argument is a tensor which is already fed to a placeholder.
# It is a 1-D tensor with the length of batch_size * max_sequence_length.
# In this partitions tensor, you need to set the last output idx for each seq to 1 and
# others remain 0, so that the result could be separated to two parts,
# one is the last outputs and the other one is the non-last outputs.
res_out = tf.dynamic_partition(outputs, partitions, num_partitions)
# prediction
preds = tf.matmul(res_out[1], weights) + bias
が、これはあなたを助けることができる願っています。
ありがとうございます。これを引き起こしているオペアンプを特定するにはどうすればよいですか? – Taaam
最も簡単な方法は、コードで 'tf.gather()'または 'tf.nn 'を調べることです。embedding_lookup() '呼び出しを実行し、それらのoppsの' params'(最初の)引数であるテンソル 't'を見つけ、' t.op'を出力します。一般に、 't'が' tf.Variable'であれば最高のパフォーマンスを得ますが、 'tf.concat()'のようないくつかのオプションではグラデーションを効率的にする特殊化があります。 – mrry
'reshape'を与えられた' boolean_mask'のようです。これは、複数の 'reshape'、' pack's、 'tile's、' expand_dim's、 'squeeze's、' batch_matmul'sなどのグラフの中の損失計算に使用されます。どのopが疎なグラデーションを受け入れることができないのかを特定する – Taaam