私はpythonテンソルを使用して、モデルを訓練してpythonでイメージを認識しています。以下はgithubOSError:pythonでprint()を使用すると、raw write()が無効な長さを返しました
Traceback (most recent call last):
File "train.py", line 1023, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "C:\Users\sande\Anaconda3\envs\tensorflow\lib\site-
packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train.py", line 766, in main
bottleneck_tensor)
File "train.py", line 393, in cache_bottlenecks
jpeg_data_tensor, bottleneck_tensor)
File "train.py", line 341, in get_or_create_bottleneck
bottleneck_tensor)
File "train.py", line 290, in create_bottleneck_file
print('Creating bottleneck at ' + bottleneck_path)
OSError: raw write() returned invalid length 112 (should have been between 0
and 56)
からtrain.pyを実行しようとしたときしかし、私はそのbottleneck_pathがされるように、ファイル名を削減しようとした
def create_bottleneck_file(bottleneck_path, image_lists, label_name, index,
image_dir, category, sess, jpeg_data_tensor,
bottleneck_tensor):
"""Create a single bottleneck file."""
print('Creating bottleneck at ' + bottleneck_path)
image_path = get_image_path(image_lists, label_name, index,
image_dir, category)
if not gfile.Exists(image_path):
tf.logging.fatal('File does not exist %s', image_path)
image_data = gfile.FastGFile(image_path, 'rb').read()
try:
bottleneck_values = run_bottleneck_on_image(
sess, image_data, jpeg_data_tensor, bottleneck_tensor)
except:
raise RuntimeError('Error during processing file %s' % image_path)
bottleneck_string = ','.join(str(x) for x in bottleneck_values)
with open(bottleneck_path, 'w') as bottleneck_file:
bottleneck_file.write(bottleneck_string)
create_bottleneck_file()のコード以下のエラーが発生しているそうです小さい値だが、うまくいかなかった。私はこのエラーをオンラインで検索しようとしましたが、役に立たないものは何も見つかりませんでした。あなたはこの問題への修正がある場合は私に知らせてください
問題はあなたがWindows上でアプリケーションを実行していると思いますが、コードはLinuxまたはMac OS用です。行338で 'print(bottleneck_path)'を実行すると、出力はどうなりますか? – MatthewScarpino
私はcmdが動作していたときにcmdをやり取りしたと思います。おそらくこれが役立ちます。https://stackoverflow.com/questions/48371993/tqdm-crashes-on-windows-console-upon-accidental-mouse-keyboard-input/48374209# 48374209 –