I have a model which was trained on MNIST, but when I put in a handmade sample of an image it raises ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 784 but received input with shape (None, 1)
I already checked the input of the model it is in the same shape as MNIST. x_train[0].shape (784,) and my image arr.shape (784,) Please help!
...
from tensorflow.keras.datasets import fashion_mnist
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras import utils
from tensorflow.keras.preprocessing import image
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
%matplotlib inline
print(x_train[3].shape)
x_train = x_train.reshape(60000, 784)
x_train = x_train / 255
model = Sequential()
model.add(Dense(800, input_dim=784, activation="relu"))
model.add(Dense(10, activation="softmax"))
model.compile(loss="categorical_crossentropy", optimizer="SGD", metrics=["accuracy"])
history = model.fit(x_train, y_train,
batch_size=200,
epochs=100,
verbose=1)
predictions = model.predict(x_train)
n = 0
plt.imshow(x_train[n].reshape(28, 28), cmap=plt.cm.binary)
plt.show()
x_train[0].shape #Out[28]: (784,)
import matplotlib.image as mpimg
import numpy as np
from PIL import Image
img = Image.open('yboot.jpg').convert('L')
arr = np.asarray(img, dtype=np.float64)
arr = arr.reshape(784)
arr.shape
arr = arr/255
print(arr.shape) # (784,)
RealPred = model.predict(arr)
ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 784 but received input with shape (None, 1)