python运行程序后不显示图像是什么原因,为什么plt.imshow()不显示图像?

在尝试运行一个包含matplotlib的Keras程序时,发现imshow()函数没有显示图像。尽管其他matplotlib图像能正常显示,但imshow()在处理MNIST数据集时未输出结果。解决方案是在imshow()之后添加plt.show(),这使得图像得以正确显示。
摘要由CSDN通过智能技术生成

I am a newbie to keras, and when I tried to run my first keras program on my linux, something just didn't go as I wish.

Here is my python code:

import numpy as np

np.random.seed(123)

from keras.models import Sequential

from keras.layers import Dense, Dropout, Activation, Flatten

from keras.layers import Convolution2D, MaxPooling2D

from keras.utils import np_utils

from keras.datasets import mnist

(X_train,y_train),(X_test,y_test) = mnist.load_data()

print X_train.shape

from matplotlib import pyplot as plt

plt.imshow(X_train[0])

The last sentence doesn't display anything. I copied those codes from a tutorial with out any modification. And there is nothing wrong with the backend of matplotlib on my computer. I have tested that through the code below.

import matplotlib.pyplo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值