初學tensorflow遇到的Error——UnrecognizedFlagError: Unknown command line flag 'f'


最近在學習《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 ^_^。

 

以后不要太死心眼…


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM