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

首頁 > 編程 > Python > 正文

tensorflow實現(xiàn)加載mnist數(shù)據(jù)集

2020-01-04 14:33:50
字體:
來源:轉載
供稿:網友

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

import numpy as npimport tensorflow as tfimport matplotlib.pyplot as pltfrom tensorflow.examples.tutorials.mnist import input_data#數(shù)據(jù)集存放地址,采用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)#輸出幾張數(shù)字的圖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

tensorflow,加載,mnist,數(shù)據(jù)集

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

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


注:相關教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 云南省| 苏尼特右旗| 怀远县| 泉州市| 江永县| 永定县| 维西| 辽宁省| 博湖县| 綦江县| 雷山县| 江阴市| 壶关县| 桐城市| 灌南县| 西宁市| 抚宁县| 留坝县| 分宜县| 汾阳市| 赤水市| 新绛县| 溆浦县| 郴州市| 塔城市| 平陆县| 哈巴河县| 永年县| 赤城县| 苏州市| 普兰店市| 玛纳斯县| 梧州市| 封丘县| 社旗县| 电白县| 瑞安市| 尤溪县| 乐业县| 霍林郭勒市| 诏安县|