2017-11-12 18 views
0

予測されたラベルを付けてテスト画像を表示したい。予測を使ってテスト画像を表示する方法

train_step.run(feed_dict={x: images32, y_: one_hot_lables}) 
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1)) 
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) 

print(accuracy.eval(feed_dict={x: test_images32, y_: T_one_hot_lables})) 

Iのみ印刷結果が、私はtest_images32内のすべての画像を表示します。これは、当然データの形状に依存するが、一般的な深い学習の問題のために、私はmatplotlibのを使用して、次の方法を使用したラベル

答えて

0

を予測。これをインタラクティブにし、それぞれの画像が表示されるのを待つためにplt.ion()を使用してこれを拡張することができます。

import matplotlib.pyplot as plt 

predictions = sess.run(y, {feed_dict={x: test_images32}}) 
for i, image in enumerate(test_images32): 
    plt.imshow(image) # depending on being RGB or gray this might need to be reshaped 
    print(np.argmax(predictions[i])) 
関連する問題