This is my DataSet
import keras
print(keras.__version__)
mnist = keras.datasets.mnist
(x_train,y_train),(x_test,y_test) = mnist.load_data()
I have performed normalizing
x_train = keras.utils.normalize(x_train,axis=1)
x_test = keras.utils.normalize(x_test,axis=1)
And built a model
model = keras.models.Sequential()
model.add(keras.layers.Flatten(x_train))
model.add(keras.layers.Dense(128,activation= keras.nn.relu))
model.add(keras.layers.Dense(128,activation= keras.nn.relu))
model.add(keras.layers.Dense(10,activation= keras.nn.softmax))
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics = ['accuracy']
)
model.fit(x_train,y_train,epochs=3)
I am getting the below error:
Using TensorFlow backend.
2.3.1
Traceback (most recent call last):
File "/Users/aditya/Desktop/Desktop/dataScience/Practice/OpenCV/FaceDetect/Hackathon/classMnist.py", line 28, in <module>
model.add(keras.layers.Flatten(x_train))
File "/usr/local/lib/python3.7/site-packages/keras/layers/core.py", line 495, in __init__
self.data_format = K.normalize_data_format(data_format)
File "/usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 311, in normalize_data_format
data_format = value.lower()
AttributeError: 'numpy.ndarray' object has no attribute 'lower'
The problem is that the Keras can't flatten my x_train dataset. Do you have nay idea why is this hapenning?