TensorFlow에서 FLAGS가 필요한 이유를 이해할 수 없습니다. 이제 TensorFlow를 저의 책에서 공부합니다.깃발이 필요한 이유는 무엇입니까?
# 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,"path")
tf.app.flags.DEFINE_integer('offset',0,"record")
tf.app.flags.DEFINE_integer('length',16,"change record")
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()
나는이 코드처럼 쓰고, 나는
FLAGS = tf.app.flags.FLAGS
이 부분을 이해할 수 없습니다. FLAGS는 오류 메시지 라벨을 읽었지 만 언제 필요합니까? (아마도 내 정보가 잘못되었을 수 있습니다) 이 파트가 필요한 이유는 무엇입니까? 이 파트에는 어떤 기능이 있습니까?