LoginSignup
1
1

More than 3 years have passed since last update.

MNISTの行列表示

Posted at

python==3.7.9
Keras==2.2.4
tensorflow==1.13.1

mnistを画像表示する


import urllib.request
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np


#prox = urllib.request.build_opener()
#urllib.request.install_opener(prox)


from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()


plt.imshow(x_train[0])

image.png

行列で表示

通常のprintではmatrix形式が省略されてつぶれてしまうが
linewidthに一行に表示する文字数を指定することで見やすくする

np.set_printoptions(linewidth = 115, precision = 1)

print(x_train[0])

スペースを含み115文字で表示できる。

image.png

以上

1
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
1
1