Ubuntu 14.04 LTS desktop amd64
GeForce GTX 750 Ti
ASRock Z170M Pro4S [Intel Z170chipset]
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v7.5
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
TensorFlowというDeep Learningのフレームワークを学習中。
TensorFlowを遊び倒す! 4-1. Convolutional Neural Networks
http://blog.brainpad.co.jp/entry/2016/04/22/170000
CIFAR-10のデータセットを処理するTutorialを読んでいる。
これまで読んできたpythonコードは主に以下のものだった。
def main(_):
if tf.gfile.Exists(FLAGS.summaries_dir):
tf.gfile.DeleteRecursively(FLAGS.summaries_dir)
tf.gfile.MakeDirs(FLAGS.summaries_dir)
train()
cifar10_train.pyのmain()の定義は以下になっている。
...
def main(argv=None): # pylint: disable=unused-argument
cifar10.maybe_download_and_extract()
if tf.gfile.Exists(FLAGS.train_dir):
tf.gfile.DeleteRecursively(FLAGS.train_dir)
tf.gfile.MakeDirs(FLAGS.train_dir)
train()
...
main()の定義においてargv=None
という記載ができるようだ。
関連 http://www.artima.com/weblogs/viewpost.jsp?thread=4829
First, we change main() to take an optional 'argv' argument, which allows us to call it from the interactive Python prompt:
def main(argv=None):
if argv is None:
argv = sys.argv
# etc., replacing sys.argv with argv in the getopt() call.
Note that we fill in the default for argv dynamically. This is more flexible than writing
def main(argv=sys.argv):
# etc.