Smu*_*ain 3 matplotlib python-3.x tensorflow
我尝试用 100,100,1 绘制图像,但出现这样的错误
TypeError: Invalid shape (100, 100, 1) for image data
Run Code Online (Sandbox Code Playgroud)
这是代码
sample_training_images, _ = next(traindata)
def plotImages(images_arr):
fig, axes = plt.subplots(1, 5, figsize=(20,20))
axes = axes.flatten()
for img, ax in zip( images_arr, axes):
ax.imshow(img)
ax.axis('off')
plt.tight_layout()
plt.plot(images_arr)
plt.show()
plotImages(sample_training_images[:5])
Run Code Online (Sandbox Code Playgroud)
img用。。。来代替img[:,:,0]:
ax.imshow(img[:,:,0], cmap='gray')
Run Code Online (Sandbox Code Playgroud)
并且可能删除plt.plot(images_arr)
| 归档时间: |
|
| 查看次数: |
10329 次 |
| 最近记录: |