TensorFlow: การแสดงภาพ จากฐานข้อมูล mnist

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

DATA_DIR = './tmp/data'
data = input_data.read_data_sets(DATA_DIR, one_hot=True)

batch_xs1, batch_ys1 = data.train.next_batch(MINIBATCH_SIZE)

import matplotlib.pyplot as plt
first_array=batch_xs1[0] # ได้ shape (784,) ต้อง reshape เป็น 28,28
plt.gray() # ให้แสดงเป็นภาพ gray scale
plt.imshow(first_array.reshape([28,28]))
#Actually displaying the plot if you are not in interactive mode
plt.show()


ที่มา: https://stackoverflow.com/questions/38308378/tensorflow-show-image-from-mnist-dataset

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

CASIO fx-5800P : การ mod ด้วยเครื่องคิดเลข

sgsBB(SGS-Score Inserter) : โปรแกรมช่วยกรอกผลคะแนนจาก bookmark51 ใส่ระบบ SGS ของ สพฐ.

springMVC : เชื่อมต่อฐานข้อมูล mySQL ด้วย JDBC-Template