How can i solve this error// TypeError: Invalid shape () for image data

chabeomsoo: <p>from <strong>future</strong> import absolute_import, division, print_function, unicode_literals, unicode_literals</p>
<h1>tensorflow와 tf.keras를 임포트합니다</h1>
<p>import tensorflow as tf<br>
from tensorflow import keras</p>
<h1>헬퍼(helper) 라이브러리를 임포트합니다</h1>
<p>import numpy as np<br>
import matplotlib.pyplot as plt</p>
<p>print(tf.<strong>version</strong>)</p>
<p>fashion_mnist = keras.datasets.fashion_mnist<br>
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()<br>
print(fashion_mnist)</p>
<p>class_names = [‘T-shirt/top’, ‘Trouser’, ‘Pullover’, ‘Dress’, ‘Coat’, ‘Sandal’, ‘Shirt’, ‘Sneaker’, ‘Bag’, ‘Ankle boot’]<br>
print(class_names)</p>
<p>print(train_images.shape)<br>
print(len(train_labels))<br>
print(train_labels)</p>
<p>print(test_images.shape)<br>
print(len(test_labels))<br>
print(test_labels)</p>
<p>plt.figure()<br>
plt.imshow(train_images[0])<br>
plt.colorbar()<br>
plt.grid(False)<br>
plt.show()</p>
<p>train_images = train_labels / 255.0<br>
test_images = test_images / 255.0</p>
<p>plt.figure(figsize=(10, 10))<br>
for i in range(25):<br>
plt.subplot(5, 5, i+1)<br>
plt.xticks([])<br>
plt.yticks([])<br>
plt.grid(False)<br>
plt.imshow(train_images[i], cmap=plt.cm.binary)   <span class="hashtag">#here</span> &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;<br>
plt.xlabel(class_names[train_labels[i]])<br>
plt.show()</p>
<p>model = keras.Sequential([<br>
keras.layers.Flatten(input_shape=(28, 28)),<br>
keras.layers.Dense(128, activation=‘relu’),<br>
keras.layers.Dense(10, activation=‘softmax’)<br>
])</p>
<p>Traceback (most recent call last):<br>
File “C:/Users/chabu/PycharmProjects/untitled1/ke.py”, line 50, in <br>
plt.imshow(train_images[i], cmap=plt.cm.binary)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib\pyplot.py”, line 2683, in imshow<br>
None else {}), **kwargs)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib_<em>init</em>_.py”, line 1601, in inner<br>
return func(ax, *map(sanitize_sequence, args), **kwargs)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py”, line 369, in wrapper<br>
return func(*args, **kwargs)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py”, line 369, in wrapper<br>
return func(*args, **kwargs)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib\axes_axes.py”, line 5671, in imshow<br>
im.set_data(X)<br>
File “C:\Users\chabu\Anaconda3\lib\site-packages\matplotlib\image.py”, line 690, in set_data<br>
.format(self._A.shape))<br>
TypeError: Invalid shape () for image data</p>

ptrblck: <p>Hi <a class="mention" href="/u/chabeomsoo">@chabeomsoo</a>,</p>
<p>your problem seems to be related to a Keras model and <code>matplotlib</code>, so I think you could get way better help in their discussion boards, since you’ve landed in the PyTorch board. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"><br>
That being said, <code>plt.imshow</code> expects image data as <code>[height, width, 3]</code>.</p>

chabeomsoo: <p>thanks you,<br>
how can i find PyTorch board ??</p>

ptrblck: <p>By “board” I meant this discussion forum. <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

Vaseekaran-V: <p>Hi<br>
Same issue happened to me. Updating your matplotlib to the current version would solve this issue.</p>