如果我有一个形状为[None, None, None, 10]
的输入,我想做类似以下的事情,
input = tf.placeholder([None, None, None, 10], dtype=tf.float32)
length = tf.placeholder([None, None], dtype=tf.int32)
cell = tf.nn.rnn_cell.BasicLSTMCell(num_units=10)
def fn(inp):
output, _ = tf.dynamic_rnn(cell, inp[0], sequence_length=inp[1])
return output
tf.map_fn(fn, (input, length), dtype=tf.float32)
但它不适用于自动梯度推导,它会产生如下错误,
Cannot use 'XXX' as input to 'gradients/YYY/while/TensorArrayWrite/TensorArrayWriteV3_grad/TensorArrayReadV3/f_acc'
because 'XXX' is in a while loop.
这是TensorFlow
的限制,它无法处理嵌套的while_loop
(dynamic_rnn
和map_fn
在场景后面运行while_loop
,或者有办法解决这个问题吗?
答案 0 :(得分:1)
TensorFlow 1.6修复了此问题