2017-09-21 1 views
2

双方向LSTMへの入力として供給される前に画像を処理する方法を知りたい。私はかなり双方向LSTMネットワークへの入力としての画像の使用

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 
+0

私は、提供されたコードとエラーを使用して正確なエラーをトレースすることはできませんが(完全なスタックトレースは一般的に単なるエラーよりも有用です)、私の推測では、メソッドが期待するPythonリストを渡しているテンソル。 – iga

+0

は、ここでは、コードとスタックトレースを含む主旨だ https://gist.github.com/selcouthlyBlue/ee06c170ea22ee82695a219e871f9c2c –

+0

これは問題ですが、bidirectional_dynamic_rnnためのドキュメントは 'あなたのケースでinputs'( 'X'を必要とする場合はわかりません)をテンソルまたはテンソルのタプルにすることができます。要点のコードでは、これは 'tf.unstack'によって返されるリストです。なぜあなたは 'tf.unstack'を呼び出す必要があるのか​​分かりません。 – iga

答えて

0

outputs, _, _ = tf.nn.bidirectional_dynamic_rnn(lstm_fw_cell, lstm_bw_cell, x, dtype=tf.float32) 

ここで問題に関連して私のコードの一部だ:この行から

AttributeError: 'list' object has no attribute 'get_shape' 

:私は、コード私を実行するたびに、私はいつもこのエラーが出ますこれをあきらめてsomething elseを作った。このようなTFLearnの機能は使用しません。私が取り組んでいる最近の問題には、hereを見ることができます。

関連する問題