我正在修改 CNN 的张量板示例代码: https://www.tensorflow.org/tutorials/deep_cnn#launching_and_training_the_model
我收到此错误:
DuplicateFlagError: The flag 'batch_sizes' is defined twice. First from D:/UofU/.../mycifar10.py, Second from D:/UofU/.../mycifar10.py. (Where both path names are the same) Description from first occurrence: Numbers of images to process in a batch.
这是产生错误的代码要点:
tf.app.flags.DEFINE_integer('batch_size', 49,
"""Numbers of images to process in a batch.""")
最佳答案
看起来您正在运行定义 batch_size
参数的代码块两次。也许它在一个函数内,并且您多次调用它,或者以其他方式调用它。
可能,如果您从 jupyter 笔记本运行它,并且您正在重新运行单元(可能在进行一些代码更改之后),则标志不会被清除,并且您正在尝试再次定义它。在这种情况下,您必须在每次运行此单元之前重新启动运行时,或者将标志分离到它们自己的单元中,运行一次,然后运行并重新运行其余代码。
如果这些都不适用,您必须发布您的代码,包括如何运行它的描述,以便能够说明更多信息。
关于python - 张量板重复标志错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50262618/