求助 tf.io.TFRecordWriter IO错误
发布于 13天前 作者 xzgtensor 来自问答
使用TFRecordWriter时候出错,
Writer=tf.io.TFRecordWriter('C:/Users/xzg/Desktop')
Writer.close()

错误如下:

Traceback (most recent call last):
File "c:\Users\xzg\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\xzg\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\xzg\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "D:\Users\xzg\Anaconda3\envs\tensorflow\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "D:\Users\xzg\Anaconda3\envs\tensorflow\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "D:\Users\xzg\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\xzg\Desktop\pytf\pylearn\mnist.py", line 94, in <module>
Writer=tf.io.TFRecordWriter('C:/Users/xzg/Desktop')
File "D:\Users\xzg\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\lib\io\tf_record.py", line 218, in __init__
compat.as_bytes(path), options._as_record_writer_options(), status)
File "D:\Users\xzg\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\errors_impl.py", line 556, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.UnknownError: Failed to create a NewWriteableFile: C:/Users/xzg/Desktop : \udcbe芫\udcf8\udcb7\udcc3\udcce省\udca3
; Input/output error


1回复

找到错误了,原来是没有指定文件名~~~~(>_<)~~~~ 下面是代码,执行后就会创建一个xzgmnist文件 真的没有注意文件路径是包含文件名的,我以为会自动给一个文件名,看来是我理解错误... writer = tf.io.TFRecordWriter('E:/tf/xuexi-mnist/xzgmnist') writer.close()

回到顶部