1. 程式人生 > 程式設計 >tensorflow mnist 資料載入實現並畫圖效果

tensorflow mnist 資料載入實現並畫圖效果

關於 TensorFlow

TensorFlow™ 是一個採用資料流圖(data flow graphs),用於數值計算的開源軟體庫。節點(Nodes)在圖中表示數學操作,圖中的線(edges)則表示在節點間相互聯絡的多維資料陣列,即張量(tensor)。它靈活的架構讓你可以在多種平臺上展開計算,例如臺式計算機中的一個或多個CPU(或GPU),伺服器,移動裝置等等。TensorFlow 最初由Google大腦小組(隸屬於Google機器智慧研究機構)的研究員和工程師們開發出來,用於機器學習和深度神經網路方面的研究,但這個系統的通用性使其也可廣泛用於其他計算領域。

Tensorflow是谷歌公司在2015年9月開源的一個深度學習框架。

正文開始:

直接看程式碼:

%matplotlib
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt

mnist = input_data.read_data_sets('MNIST_data',one_hot=True)

print('Training data size: ',mnist.train.num_examples)
print('Validation data size: ',mnist.validation.num_examples)
print('Test data size: ',mnist.test.num_examples)

img0 = mnist.train.images[0].reshape(28,28)
img1 = mnist.train.images[1].reshape(28,28)
img2 = mnist.train.images[2].reshape(28,28)
img3 = mnist.train.images[3].reshape(28,28)

fig = plt.figure(figsize=(10,10))
ax0 = fig.add_subplot(221)
ax1 = fig.add_subplot(222)
ax2 = fig.add_subplot(223)
ax3 = fig.add_subplot(224)

ax0.imshow(img0)
ax1.imshow(img1)
ax2.imshow(img2)
ax3.imshow(img3)
fig.show()

畫圖結果:

tensorflow mnist 資料載入實現並畫圖效果

總結

以上所述是小編給大家介紹的tensorflow mnist 資料載入實現並畫圖效果,希望對大家有所幫助!