From 86f7d660ede4df624222fc49f0890d0cbc9b2bd2 Mon Sep 17 00:00:00 2001 From: PARK JOON GYU Date: Fri, 15 Mar 2019 13:34:26 +0900 Subject: [PATCH] Add matplotlib for the Jupyter Notebook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기존 코드로는 주피터 노트북에서 이미지가 표시되지 않아서 코드를 수정했습니다. --- .../mnist_show.py" | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git "a/ch3.\354\213\240\352\262\275\353\247\235/mnist_show.py" "b/ch3.\354\213\240\352\262\275\353\247\235/mnist_show.py" index 79090f7..74a8c88 100644 --- "a/ch3.\354\213\240\352\262\275\353\247\235/mnist_show.py" +++ "b/ch3.\354\213\240\352\262\275\353\247\235/mnist_show.py" @@ -1,19 +1,25 @@ +import os +import sys + import numpy as np -import sys, os -sys.path.append(os.pardir) -from dataset.mnist import load_mnist +import matplotlib.pyplot as plt from PIL import Image +from dataset.mnist import load_mnist + # 3.6.1 MNIST 이미지 확인해보기 +sys.path.append(os.pardir) + def img_show(img): pil_img = Image.fromarray(np.uint8(img)) - pil_img.show() + plt.imshow(pil_img) + plt.show() -(x_train, t_train), (x_test, t_test) = load_mnist(flatten=True, - normalize=False) +(x_train, t_train), (x_test, t_test) = \ + load_mnist(flatten=True, normalize=False) img = x_train[0] label = t_train[0]