flagsモジュールの必要性がわかりません。
# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import numpy as np import tensorflow as tf from PIL import Image from reader import Cifar10Reader FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string('file',None,"処理するファイルのパス") tf.app.flags.DEFINE_integer('offset',0,"読み飛ばすレコード数") tf.app.flags.DEFINE_integer('length',16,"読み込んで変換するレコード数") basename = os.path.basename(FLAGS.file) path = os.path.dirname(FLAGS.file) reader = Cifar10Reader(FLAGS.file) stop = FLAGS.offset + FLAGS.length for index in range(FLAGS.offset,stop): image = reader.read(index) print('label: %d' % image.label) imageshow = Image.fromarray(image.byte_array.astype(np.unit8)) file_name = '%s-%02d-%d.png' % (basename,index,image.label) file = os.path.join(path,file_name) with open(file,mode='wb') as out: imageshow.save(out,format='png') reader.close()
というCIFAR-10形式のデータセットを読み込むプログラムを書きました。
このコードに、
FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string('file',None,"処理するファイルのパス") tf.app.flags.DEFINE_integer('offset',0,"読み飛ばすレコード数") tf.app.flags.DEFINE_integer('length',16,"読み込んで変換するレコード数")
という部分と
stop = FLAGS.offset + FLAGS.length
という部分があると思いますが、
このflagsモジュールをなぜ書かなければならないのかわかりません。
tensorflowの公式リファレンスには
Implementation of the flags interface.
=フラッグ接点の実行(?) と書かれていますが果たしてどういう意味なのかさっぱり...。
このflagsはラベルづけと関係がありますか?
どうしてflagsモジュールが必要なのか、またこの2つの部分のコードが必要なのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。