Argparse error with TensorFlow's cifar10.py

前端 未结 1 1829
迷失自我
迷失自我 2021-01-27 05:18

I get the following error when I run python cifar10.py:

argparse.ArgumentError: argument --batch_size: conflicting option string(s): --batch_size

相关标签:
1条回答
  • 2021-01-27 06:09

    In the cifr10.py file:

    import tensorflow as tf
    
    from tensorflow.models.image.cifar10 import cifar10_input
    
    FLAGS = tf.app.flags.FLAGS
    
    # Basic model parameters.
    tf.app.flags.DEFINE_integer('batch_size', 128,
                                """Number of images to process in a batch.""")
    ....
    

    The error is produced by this last statement, which, in the _flags.py file, defines an argparse argument with that name. Evidently at this point the tf.app already has such an argument define.

    So we need to look further back at import tensorflow as tf to see how tf.app was created?

    What's the Amazon g2.2xlarge? Could that defining batch_size as well?

    Looks like tf.app comes from

    tensorflow/python/platform/app.py
    

    which in turn gets it from something like

    from tensorflow.python.platform.google._app import *
    

    So if you are running this on some google or amazon platform that itself accepts batch_size parameter, it could produce this error.


    Another question about cifr10 and the batch_size argument:

    How to use "FLAGS" (command line switches) in TensorFlow?

    Same error here:

    Tensorflow ArgumentError Running CIFAR-10 example The answer says to use cifar10_train.py,cifar10_eval.py, not cifar10.py.

    0 讨论(0)
提交回复
热议问题