Tensorflow无效参数:尝试读取字符串时数据太短

时间:2018-08-11 05:19:13

标签: python tensorflow training-data

我正在使用Tensorflow的音频识别库,但无法在库中训练自己的数据。我有自己的音频数据,为了确保正确的训练,我们已经对其进行了彻底的处理,但是当我运行train.py命令基于这些文件训练模型时,会发生此错误:

 tensorflow/core/framework/op_kernel.cc:1275] OP_REQUIRES failed at decode_wav_op.cc:55 : Invalid argument: Data too short when trying to read string
Traceback (most recent call last):
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call
    return fn(*args)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1263, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Data too short when trying to read string
     [[Node: data/DecodeWav = DecodeWav[desired_channels=1, desired_samples=72000, _device="/job:localhost/replica:0/task:0/device:CPU:0"](data/ReadFile)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tensorflow/examples/speech_commands/train.py", line 462, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "tensorflow/examples/speech_commands/train.py", line 226, in main
    FLAGS.background_volume, time_shift_samples, 'training', sess)
  File "/home/paul/Documents/tensorflow/tensorflow/examples/speech_commands/input_data.py", line 534, in get_data
    [self.merged_summaries_, self.output_], feed_dict=input_dict)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 877, in run
    run_metadata_ptr)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1100, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1272, in _do_run
    run_metadata)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1291, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Data too short when trying to read string
     [[Node: data/DecodeWav = DecodeWav[desired_channels=1, desired_samples=72000, _device="/job:localhost/replica:0/task:0/device:CPU:0"](data/ReadFile)]]

Caused by op 'data/DecodeWav', defined at:
  File "tensorflow/examples/speech_commands/train.py", line 462, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "tensorflow/examples/speech_commands/train.py", line 106, in main
    FLAGS.testing_percentage, model_settings, FLAGS.summaries_dir)
  File "/home/paul/Documents/tensorflow/tensorflow/examples/speech_commands/input_data.py", line 163, in _init_
    self.prepare_processing_graph(model_settings, summaries_dir)
  File "/home/paul/Documents/tensorflow/tensorflow/examples/speech_commands/input_data.py", line 359, in prepare_processing_graph
    wav_loader, desired_channels=1, desired_samples=desired_samples)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_audio_ops.py", line 183, in decode_wav
    desired_samples=desired_samples, name=name)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op
    op_def=op_def)
  File "/home/paul/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1717, in _init_
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Data too short when trying to read string
     [[Node: data/DecodeWav = DecodeWav[desired_channels=1, desired_samples=72000, _device="/job:localhost/replica:0/task:0/device:CPU:0"](data/ReadFile)]]``

为什么在读取文件时会出现读取字符串的错误?

0 个答案:

没有答案