質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

0回答

198閲覧

出力結果の見方がわからない

退会済みユーザー

退会済みユーザー

総合スコア0

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2017/04/25 09:44

出力結果の見方がわからないです。
モデル読み込ませて、推論で学習結果の予想を行ったのですが、
その出力結果が

[5]: [array([[ 0.02123145, 0.00887325, -0.04531521, 0.15737413, -0.00788159, 0.07157519, -0.07936244, -0.20474763, -0.06418768, 0.14273719]], dtype=float32)] [7]: [array([[ 0.26896179, -0.99437118, -0.648 , 0.29603952, 0.80033737, 0.34100154, -0.63109881, 1.83045578, -0.81493163, -0.35426903]], dtype=float32)] [7]: [array([[ -6.94188404, -4.8448987 , 3.42359805, -3.00604391, 8.83248806, 2.23456097, 0.8877517 , 18.5250721 , -15.22857666, -7.90845299]], dtype=float32)] [2]: [array([[-0.8607462 , -0.52009165, 0.26848218, 0.53520882, 0.87279713, 0.80628544, 1.6438719 , 0.29229778, -2.43464684, -0.4134081 ]], dtype=float32)] [8]: [array([[ 1.53771234, -0.33550233, -0.00823235, -0.05592023, -0.20053209, -0.35242966, -1.0516901 , -0.42457539, 1.44832718, -0.24960999]], dtype=float32)] [1]: [array([[-0.33476034, -0.2010951 , 0.18780072, 0.40470737, 0.1551768 , 0.57992721, -0.17237614, -0.2042886 , -0.1378624 , -0.27705047]], dtype=float32)] [8]: [array([[ 4.51377487, 0.67293972, -7.66615868, -6.10120583, 1.14583743, -2.21462297, -2.47279549, -2.13140392, 17.36090469, -5.58564425]], dtype=float32)]

のようでした。

まず、各結果の先頭についている、[5]・[7]・[2]・[1]・[8]の数字は一体何を表現しているのでしょうか?
あと、[ 4.51377487, 0.67293972, -7.66615868, -6.10120583,
1.14583743, -2.21462297, -2.47279549, -2.13140392,
17.36090469, -5.58564425]
のようなフロート配列の並びは何を表現しているのでしょうか?
Cifar10の画像データを読み込ませて精度を出力しているのだから、例えば
[猫のグループ 0.7]のような結果になると思うのです。

ファイルは以下のように書きました。

# coding: UTF-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import time import tensorflow as tf import model as model import numpy as np from reader import Cifar10Reader FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_integer('epoch', 30, "訓練するEpoch数") tf.app.flags.DEFINE_string('data_dir', './cifar-10-batches-bin 2/', "訓練データのディレクトリ") tf.app.flags.DEFINE_string('checkpoint_dir', './checkpoints/', "チェックポイントを保存するディレクトリ") tf.app.flags.DEFINE_string('test_data', None, "テストデータのパス") def _loss(logits, label): labels = tf.cast(label, tf.int64) cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits( logits=logits, labels=labels,name='cross_entropy_per_example') cross_entropy_mean = tf.reduce_mean(cross_entropy, name='cross_entropy') return cross_entropy_mean def _train(total_loss, global_step): opt = tf.train.GradientDescentOptimizer(learning_rate=0.001) grads = opt.compute_gradients(total_loss) train_op = opt.apply_gradients(grads, global_step=global_step) return train_op filenames = [ os.path.join( FLAGS.data_dir, 'data_batch_%d.bin' % i) for i in range(1, 6) ] def main(argv=None): global_step = tf.Variable(0,trainable=False) train_placeholder = tf.placeholder(tf.float32, shape=[32, 32, 3], name='input_image') label_placeholder = tf.placeholder(tf.int32,shape=[1],name='label') # (width, height, depth) -> (batch, width, height, depth) image_node = tf.expand_dims(train_placeholder, 0) logits = model.inference(image_node) total_loss = _loss(logits,label_placeholder) train_op = _train(total_loss,global_step) top_k_op = tf.nn.in_top_k(logits,label_placeholder,1) with tf.Session() as sess: sess.run(tf.initialize_all_variables()) total_duration = 0 for epoch in range(1, FLAGS.epoch + 1): start_time = time.time() for file_index in range(5): print('Epoch %d: %s' % (epoch, filenames[file_index])) reader = Cifar10Reader(filenames[file_index]) for index in range(10000): image = reader.read(index) logits_value = sess.run([logits], feed_dict={ train_placeholder: image.byte_array }) _,loss_value = sess.run([train_op,total_loss], feed_dict={ train_placeholder: image.byte_array, label_placeholder: image.label } ) if index % 1000 == 0: print('[%d]: %r' % (image.label, logits_value)) assert not np.isnan(loss_value), \ 'Model diverged with loss = NaN' reader.close() duration = time.time() - start_time total_duration += duration prediction = _eval(sess,top_k_op,train_placeholder,label_placeholder) print('epoch %d duration = %d sec' % (epoch, duration)) tf.summary.FileWriter(FLAGS.checkpoint_dir, sess.graph) print('Total duration = %d sec' % total_duration) def _eval(sess,top_k_op,train_placeholder,label_placeholder): if not FLAGS.test_data: return np.nan image_reader = Cifar10Reader(FLAGS.test_data) true_count = 0 for index in range(10000): image = image_reader.read(index) predictions = sess.run([top_k_op], feed_dict={ input_image: image.image, label_placeholder:image.label } ) true_count += np.sum(predictions) image_reader.close() if __name__ == '__main__': tf.app.run()

あれらの表示は何を表しているのでしょうか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問