使用图像作为双向 LSTM 网络的输入
Using Images as Input to a Bidirectional LSTM Network
我想知道在将图像作为双向 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(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
我几乎已经放弃了这个并且做了 something else work. It doesn't use the TFLearn features unlike this one. The recent one I'm working on has a problem which you can view 。
我想知道在将图像作为双向 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(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
我几乎已经放弃了这个并且做了 something else work. It doesn't use the TFLearn features unlike this one. The recent one I'm working on has a problem which you can view