使用图像作为双向LSTM网络的输入

时间:2017-09-21 03:57:45

标签: 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(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

1 个答案:

答案 0 :(得分:0)

我几乎已经放弃了这个,并使something else工作。与此不同,它不使用TFLearn功能。我正在处理的最近一个问题是您可以查看here