国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

tensorflow實現加載mnist數據集

2020-02-15 22:56:02
字體:
來源:轉載
供稿:網友

mnist作為最基礎的圖片數據集,在以后的cnn,rnn任務中都會用到

import numpy as npimport tensorflow as tfimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_data#數據集存放地址,采用0-1編碼mnist = input_data.read_data_sets('F:/mnist/data/',one_hot = True)print(mnist.train.num_examples)print(mnist.test.num_examples)trainimg = mnist.train.imagestrainlabel = mnist.train.labelstestimg = mnist.test.imagestestlabel = mnist.test.labels#打印相關信息print(type(trainimg))print(trainimg.shape,)print(trainlabel.shape,)print(testimg.shape,)print(testlabel.shape,)nsample = 5randidx = np.random.randint(trainimg.shape[0],size = nsample)#輸出幾張數字的圖for i in randidx:  curr_img = np.reshape(trainimg[i,:],(28,28))  curr_label = np.argmax(trainlabel[i,:])  plt.matshow(curr_img,cmap=plt.get_cmap('gray'))  plt.title(""+str(i)+"th Training Data"+"label is"+str(curr_label))  print(""+str(i)+"th Training Data"+"label is"+str(curr_label))  plt.show()

程序運行結果如下:

Extracting F:/mnist/data/train-images-idx3-ubyte.gzExtracting F:/mnist/data/train-labels-idx1-ubyte.gzExtracting F:/mnist/data/t10k-images-idx3-ubyte.gzExtracting F:/mnist/data/t10k-labels-idx1-ubyte.gz5500010000<class 'numpy.ndarray'>(55000, 784)(55000, 10)(10000, 784)(10000, 10)52636th 

輸出的圖片如下:

Training Datalabel is9

下面還有四張其他的類似圖片

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武威市| 万载县| 长武县| 缙云县| 久治县| 当阳市| 宜良县| 盘锦市| 修文县| 康平县| 辽阳县| 乐亭县| 遂昌县| 论坛| 孟村| 观塘区| 金川县| 湖口县| 讷河市| 麻阳| 常宁市| 瓦房店市| 大埔区| 太湖县| 彭阳县| 太仆寺旗| 文昌市| 五家渠市| 根河市| 兴国县| 开远市| 腾冲县| 广宗县| 芮城县| 于田县| 扎赉特旗| 慈溪市| 布拖县| 融水| 新疆| 通渭县|