Tensorflow 使用图像作为双向LSTM网络的输入
我想知道在作为双向LSTM的输入输入输入之前如何处理图像。每当我运行我的代码时,总是会出现以下错误:Tensorflow 使用图像作为双向LSTM网络的输入,tensorflow,lstm,Tensorflow,Lstm,我想知道在作为双向LSTM的输入输入输入之前如何处理图像。每当我运行我的代码时,总是会出现以下错误: AttributeError: 'list' object has no attribute 'get_shape' 从这一行: outputs, _, _ = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell, lstm_bw_cell, x, dtype=tf.float32) 下面是我的代码中与此问题相关的一部分: def bi_rnn(feat
AttributeError: 'list' object has no attribute 'get_shape'
从这一行:
outputs, _, _ = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell, lstm_bw_cell, x, dtype=tf.float32)
下面是我的代码中与此问题相关的一部分:
def bi_rnn(features, labels, mode):
x = tf.unstack(features, num_inputs, 1)
... # cell initialization
# Get lstm cell output
try:
outputs, _, _ = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell, lstm_bw_cell, x, dtype=tf.float32)
...
def serving_input_fn():
feature_placeholders = {
'features': tf.placeholder(tf.float32, [None, num_inputs])
}
features = {
key: tf.expand_dims(tensor, -1) for key, tensor in feature_placeholders.items()
}
features = tf.squeeze(features, axis=[2])
return InputFnOps(features, None, feature_placeholders)
def read_dataset(img_paths, labels):
def _input_fn():
... # reading image paths omitted
image_files = tf.image.decode_png(image_files)
image_files = tf.image.resize_images(image_files, [1024, 128])
image_files = evaluate_images(image_files)
... # labels part omitted
return tf.convert_to_tensor(np.array(image_files)), labels2
return _input_fn
我几乎已经放弃了这一点,开始工作了。它没有使用与此不同的TFLearn功能。我最近正在处理的一个问题,您可以查看。我无法使用提供的代码和错误跟踪确切的错误(具有完整堆栈跟踪通常比仅跟踪错误更有用),但我猜您正在传递一个python列表,其中该方法需要一个张量。下面是包含代码和堆栈跟踪的要点,不确定这是否是问题所在,但双向动态文档要求
输入(x
)是张量或张量元组。在gist中的代码中,它是一个列表(由tf.unstack
返回)。我不知道你为什么需要在那里调用tf.unstack
?