我正试着从训练目录中画出一堆增强图像。我用的是Keras和Tensorflow。可视化库是matplotlib。我使用下面的代码在6行和列中绘制256 X 256 X 1灰色图像。我得到的错误是Invalid Dimensions for image data.
这是我的密码使用:-在
^{pr2}$
下面是error和python的快照回溯:在---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 plot_images(train_batches, "Augmented Images")
in plot_images(img_gen, img_title)
8 for j in range(6):
9 if i*6 + j < 32:
---> 10 ax[i][j].imshow(img[i*6 + j])
11 break
~/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1896 warnings.warn(msg % (label_namer, func.__name__),
1897 RuntimeWarning, stacklevel=2)
-> 1898 return func(ax, *args, **kwargs)
1899 pre_doc = inner.__doc__
1900 if pre_doc is None:
~/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5122 resample=resample, **kwargs)
5123
-> 5124 im.set_data(X)
5125 im.set_alpha(alpha)
5126 if im.get_clip_path() is None:
~/anaconda3/lib/python3.6/site-packages/matplotlib/image.py in set_data(self, A)
598 if (self._A.ndim not in (2, 3) or
599 (self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
--> 600 raise TypeError("Invalid dimensions for image data")
601
602 self._imcache = None
TypeError: Invalid dimensions for image data
我做错什么了?在