亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

 更新時間:2018年09月08日 10:16:08   作者:Missayaa  
這篇文章主要為大家詳細介紹了tensorflow實現(xiàn)加載mnist數(shù)據(jù)集,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from 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.images
trainlabel = mnist.train.labels
testimg = mnist.test.images
testlabel = mnist.test.labels

#打印相關(guān)信息
print(type(trainimg))
print(trainimg.shape,)
print(trainlabel.shape,)
print(testimg.shape,)
print(testlabel.shape,)

nsample = 5
randidx = 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()

程序運行結(jié)果如下:

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

輸出的圖片如下:

Training Datalabel is9

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

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論