如何更正:TypeError:“ _ FlagValues”对象在重新训练Mobilenet模型时无法下标

时间:2019-01-31 12:21:26

标签: python tensorflow image-segmentation flags

我正在尝试使用-

重新训练移动网络模型
!python tensorflow/hubmaster/examples/image_retraining/retrain.py \
--tfhub_module=https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2

但是出现以下错误-

Traceback (most recent call last):

File "tensorflow/tensorflow/hub-master/examples/image_retraining/retrain.py", line 1313, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "tensorflow/tensorflow/hub-master/examples/image_retraining/retrain.py", line 998, in main
    module_spec = hub.load_module_spec(FLAGS.tfhub_module)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow_hub/module.py", line 57, in load_module_spec
    path = registry.resolver(path)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow_hub/registry.py", line 42, in __call__
    return impl(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 77, in __call__
    module_dir = _module_dir(handle)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 45, in _module_dir
    cache_dir = resolver.tfhub_cache_dir(use_temp=True)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow_hub/resolver.py", line 68, in tfhub_cache_dir
    os.getenv(_TFHUB_CACHE_DIR, "") or FLAGS["tfhub_cache_dir"].value or

TypeError: '_FlagValues' object is not subscriptable

我尝试将os.getenv(_TFHUB_CACHE_DIR, "")中的os.getenv(TFHUB_CACHE_DIR, "")更改为resolver.py(错误的倒数第二行),如图here所示,但仍然遇到相同的错误

1 个答案:

答案 0 :(得分:0)

这是由于Tensorflow的版本较旧。我最初使用Tensorflow 1.4,在升级到Tensorflow 1.9时,我没有收到此错误