python - 错误:tensorflow:Couldn't understand architecture name '.50_%image_size%'

标签 python tensorflow machine-learning deep-learning google-colaboratory

大家好,我尝试为诗人构建基于 TensorFlow 的 imageclassifer,我使用 colab 来运行 tensorflow ,但是当我运行以下代码时

    IMAGE_SIZE=224
    ARCHITECTURE="mobilenet_0.50_${IMAGE_SIZE}"
    !python -m scripts.retrain \
      --bottleneck_dir=tf_files/bottlenecks \
      --how_many_training_steps=500 \
      --model_dir=tf_files/models/ \
      --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}" \
      --output_graph=tf_files/retrained_graph.pb \
      --output_labels=tf_files/retrained_labels.txt \
      --architecture="${ARCHITECTURE}" \
      --image_dir=tf_files/flower_photos

我收到以下错误

ERROR:tensorflow:Couldn't understand architecture name '.50_%image_size%'
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/content/tensorflow-for-poets-2/scripts/retrain.py", line 1326, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/content/tensorflow-for-poets-2/scripts/retrain.py", line 976, in main
    model_info = create_model_info(FLAGS.architecture)
  File "/content/tensorflow-for-poets-2/scripts/retrain.py", line 923, in create_model_info
    raise ValueError('Unknown architecture', architecture)
ValueError: ('Unknown architecture', '.50_%image_size%')

最佳答案

代码单元格中有两个错误。首先,您需要将 ARCHIETECTURE 变量设置为 f"mobilenet_0.50_${IMAGE_SIZE}。其次,您不应在 shell 命令中使用 $。 这是经过更正的代码。

IMAGE_SIZE=224
ARCHITECTURE=f"mobilenet_0.50_${IMAGE_SIZE}"
!python -m scripts.retrain \
  --bottleneck_dir=tf_files/bottlenecks \
  --how_many_training_steps=500 \
  --model_dir=tf_files/models/ \
  --summaries_dir=tf_files/training_summaries/"{ARCHITECTURE}" \
  --output_graph=tf_files/retrained_graph.pb \
  --output_labels=tf_files/retrained_labels.txt \
  --architecture="{ARCHITECTURE}" \
  --image_dir=tf_files/flower_photos

关于python - 错误:tensorflow:Couldn't understand architecture name '.50_%image_size%' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53082740/

相关文章:

python - threading.Lock() 与 QThread() 兼容吗? QMutex() 与 python 线程兼容吗?

python - 如何将列表拆分为大小相等的 block ?

python - 多层神经网络反向传播公式(使用随机梯度下降)

TensorFlow - 获取张量的变量范围?

algorithm - 与神经网络中的几个输出节点相比,具有多个输出节点的优点或缺点是什么

algorithm - 关于感知器算法伪代码的疑问

python - 从终端导入 python 文件

Python SQL Select 语法,中间有变量

python - 将列表转换为 n 维数组以馈送到 TFlearn

image - 关于使用预训练的 im2txt 模型