一次配列にした方が計算が早いのでしょうか?
http://www.buildinsider.net/small/booktensorflow/0201
を参考にして今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,"処理するファイルのパス") 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()
以下の部分がわかりませんでした。
imageshow = Image.fromarray(image.byte_array.astype(np.unit8))
Image.fromarrayは画像のLGBの配列を一次配列にするものですが、
一次配列にした方が計算が早いのでしょうか?
どうしてわざわざ一次配列にしてsave
imageshow.save(out,format='png')
しているのでしょうか?
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/04/12 03:14
2017/04/12 03:24
2017/04/12 03:31
退会済みユーザー
2017/04/12 03:34