2017-05-01 15 views
0

シーケンスをテンソルフローのシーケンスモデルに訓練しようとすると、この奇妙なエラーが発生します。シーケンスからシーケンスへのモデルはビデオ字幕システムです。 SequenceExampleProtoのシーケンスフィーチャでビデオのフレームをエンコードしました。私は、JPEGエンコードされた文字列のリストを含む機能をプリフェッチした後、私は彼らが次の関数を使用してデコード:実装されていないエラー:TensorArrayのサイズがゼロ

video = tf.map_fn(lambda x: tf.image.decode_jpeg(x, channels=3), encoded_video, dtype=tf.uint8) 

モデルはコンパイルが、トレーニング時間の間に、私はこのコードによって引き起こされる、次のエラーを取得しています。このエラーは、TensorArrayがゼロであるのに対し、TensorArrayはゼロではないはずです。どんな助けもありがたいです。

tensorflow.python.framework.errors_impl.UnimplementedError: TensorArray has size zero, but element shape [?,?,3] is not fully defined. Currently only static shapes are supported when packing zero-size TensorArrays. 
    [[Node: input_fn/decode/map/TensorArrayStack/TensorArrayGatherV3 = TensorArrayGatherV3[_class=["loc:@input_fn/decode/map/TensorArray_1"], dtype=DT_UINT8, element_shape=[?,?,3], _device="/job:localhost/replica:0/task:0/cpu:0"](input_fn/decode/map/TensorArray_1, input_fn/decode/map/TensorArrayStack/range, input_fn/decode/map/while/Exit_1/_479)]] 

Caused by op u'input_fn/decode/map/TensorArrayStack/TensorArrayGatherV3', defined at: 
    File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main 
    "__main__", fname, loader, pkg_name) 
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code 
    exec code in run_globals 
    File "/home/ubuntu/ASLNet/seq2seq/bin/train.py", line 277, in <module> 
    tf.app.run() 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run 
    _sys.exit(main(_sys.argv[:1] + flags_passthrough)) 
    File "/home/ubuntu/ASLNet/seq2seq/bin/train.py", line 272, in main 
    schedule=FLAGS.schedule) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/learn_runner.py", line 111, in run 
    return _execute_schedule(experiment, schedule) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/learn_runner.py", line 46, in _execute_schedule 
    return task() 
    File "seq2seq/contrib/experiment.py", line 104, in continuous_train_and_eval 
    monitors=self._train_monitors) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 281, in new_func 
    return func(*args, **kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 430, in fit 
    loss = self._train_model(input_fn=input_fn, hooks=hooks) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 925, in _train_model 
    features, labels = input_fn() 
    File "seq2seq/training/utils.py", line 274, in input_fn 
    frame_format="jpeg") 
    File "seq2seq/training/utils.py", line 365, in process_video 
    video = tf.map_fn(lambda x: tf.image.decode_jpeg(x, channels=3), encoded_video, dtype=tf.uint8) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/functional_ops.py", line 390, in map_fn 
    results_flat = [r.stack() for r in r_a] 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/tensor_array_ops.py", line 301, in stack 
    return self.gather(math_ops.range(0, self.size()), name=name) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/tensor_array_ops.py", line 328, in gather 
    element_shape=element_shape) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 2244, in _tensor_array_gather_v3 
    element_shape=element_shape, name=name) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op 
    op_def=op_def) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2336, in create_op 
    original_op=self._default_original_op, op_def=op_def) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1228, in __init__ 
    self._traceback = _extract_stack() 

UnimplementedError (see above for traceback): TensorArray has size zero, but element shape [?,?,3] is not fully defined. Currently only static shapes are supported when packing zero-size TensorArrays. 
    [[Node: input_fn/decode/map/TensorArrayStack/TensorArrayGatherV3 = TensorArrayGatherV3[_class=["loc:@input_fn/decode/map/TensorArray_1"], dtype=DT_UINT8, element_shape=[?,?,3], _device="/job:localhost/replica:0/task:0/cpu:0"](input_fn/decode/map/TensorArray_1, input_fn/decode/map/TensorArrayStack/range, input_fn/decode/map/while/Exit_1/_479)]] 

答えて

0

固定されています。私はtensorflow map_fn TensorArray has inconsistent shapesからの提案に続き、以下を実装しました:

with tf.name_scope("decode", values=[encoded_video]): 
    input_jpeg_strings = tf.TensorArray(tf.string, video_length) 
    input_jpeg_strings = input_jpeg_strings.unstack(encoded_video) 
    init_array = tf.TensorArray(tf.float32, size=video_length) 

    def cond(i, ta): 
     return tf.less(i, video_length) 

    def body(i, ta): 
     image = input_jpeg_strings.read(i) 
     image = tf.image.decode_jpeg(image, 3, name='decode_image') 
     image = tf.image.convert_image_dtype(image, dtype=tf.float32) 
     assert (resize_height > 0) == (resize_width > 0) 
     image = tf.image.resize_images(image, size=[resize_height, resize_width], method=tf.image.ResizeMethod.BILINEAR) 
     return i + 1, ta.write(i, image) 

    _, input_image = tf.while_loop(cond, body, [0, init_array]) 
関連する問題