最近在学习《tensorflow实战》时需要下载cifar10数据集,在cifar10目录下用到命令:
import cifar10,cifar10_input
cifar10.maybe_download_and_extract()
出错,具体错误信息
UnrecognizedFlagError Traceback (most recent call last) <ipython-input-2-e6d19815ade8> in <module>() 15 return var 16 ---> 17 cifar10.maybe_download_and_extract() 18 images_train,labels_train = cifar10_input.disorted_inputs(data_dir=data_dir,batch_size=batch_size) 19 images_test,labels_test = cifar10_input.inputs(eval_data=True,data_dir=data_dir,batch_size=batch_size) ~/ml/models/tutorials/image/cifar10/cifar10.py in maybe_download_and_extract() 379 def maybe_download_and_extract(): 380 """Download and extract the tarball from Alex's website.""" --> 381 dest_directory = FLAGS.data_dir 382 if not os.path.exists(dest_directory): 383 os.makedirs(dest_directory) ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/flags.py in __getattr__(self, name) 82 # a flag. 83 if not wrapped.is_parsed(): ---> 84 wrapped(_sys.argv) 85 return wrapped.__getattr__(name) 86 ~/anaconda3/lib/python3.6/site-packages/absl/flags/_flagvalues.py in __call__(self, argv, known_only) 628 suggestions = _helpers.get_flag_suggestions(name, list(self)) 629 raise _exceptions.UnrecognizedFlagError( --> 630 name, value, suggestions=suggestions) 631 632 self.mark_as_parsed() UnrecognizedFlagError: Unknown command line flag 'f'
把这个错误信息从头到尾读了一遍,什么玩意儿??
抓耳挠腮,谷歌走一波。
完全相符的结果不多,看了上面的解决方法貌似也都不太适合我,但是从https://github.com/tensorflow/tensorflow/issues/17702,看到
也就是说他的这段出错的代码在python命令行是可以运行的。
坑爹的jupyter?
不不不,jupyter还是很方便的,jupyter牛逼!
但是怎么解决呢,继续搜索,直到大神一句话醍醐灌顶
https://github.com/jupyter/notebook/issues/3327
大神原话可能不是这个意思,但是说者无心听者有意加上我英语渣:为什么非要在jupyter上跑这行代码?就一个下载功能,直接用脚本跑呗。于是…
problem solved ^_^。
以后不要太死心眼…