[英]How can I fix the ValueError when building the model in TensorFlow?
When I run the code written on https://github.com/MG2033/ShuffleNet , just by running python main.py --config config/test.json
, I get the following error when buling the model: 当我运行在https://github.com/MG2033/ShuffleNet上编写的代码时,仅通过运行
python main.py --config config/test.json
,在修改模型时出现以下错误:
Building the model...
Traceback (most recent call last):
File "main.py", line 69, in <module>
main()
File "main.py", line 35, in main
model = ShuffleNet(config_args)
File "/home/farzaneh/PycharmProjects/shufflenet code/ShuffleNet-master/model.py", line 29, in __init__
self.__build()
File "/home/farzaneh/PycharmProjects/shufflenet code/ShuffleNet-master/
model.py", line 134, in __build
self.__init_output()
File "/home/farzaneh/PycharmProjects/shufflenet code/ShuffleNet-master /model.py", line 91, in __init_output
self.check_op = tf.add_check_numerics_ops()
File "/home/farzaneh/anaconda3/lib/python3.6/site-packages/tensorflow /python/ops/numerics.py", line 75, in add_check_numerics_ops
raise ValueError("`tf.add_check_numerics_ops() is not compatible "
ValueError: `tf.add_check_numerics_ops() is not compatible with TensorFlow control flow operations such as `tf.cond()` or `tf.while_loop()`.
How can I fix it? 我该如何解决?
According to the readme of shuffle.NET, you need to provide a path to the config file as argument, as following: python main.py --config config/test.json
. 根据shuffle.NET的自述文件,您需要提供配置文件的路径作为参数,如下所示:
python main.py --config config/test.json
。 And there should be a config. 并且应该有一个配置。
EDIT: After I looked into it: 编辑:我调查了之后:
Apparently, the error is right and add_check_numerics_ops is incompatible with while_loops and stuff. 显然,错误是正确的,并且add_check_numerics_ops与while_loops和东西不兼容。 In the code you can also see that this line was just added for debugging to handle nans, which normally should not occur.
在代码中,您还可以看到此行只是为了调试以处理nans而添加的,通常不会发生。 Therefore I guess you can just comment out this part.
因此,我想您可以只注释掉这部分。 Finally I found that there is this issue on the project too, which gives me the feeling that there is really an issue with the code.
最终,我发现项目上也存在此问题 ,这使我感到代码确实存在问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.