LoginSignup
0
1

More than 5 years have passed since last update.

[tensorflow] MNISTデータセットの分析

Last updated at Posted at 2018-03-13

tensorflowでMNISTデータセットを使う

python
from tensorflow.examples.tutorials.mnist import input_data
import cv2
import numpy as np

# なかったら自動でダウンロードされる
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)

# 訓練
tr = mnist.train.images
# 試験
te = mnist.test.images
# 評価
va = mnist.validation.images

# (55000, 784)
print(tr.shape)
# (10000, 784)
print(te.shape)
# (5000, 784)
print(va.shape)

# (10000, 784) -> (10000, 28, 28)
te = np.reshape(te, (-1, 28, 28))

# numpyでsave
np.save('example.npy', te)
# numpyでload
te = np.load('example.npy')

# 7が表示される
cv2.imshow('', te[0,:,:])
cv2.waitKey(0)

MNISTの構成

mnist.train
mnist.test
mnist.validation
mnist.(..).images
mnist.(..).labels

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1