I’m following an book example, using the fashion MNIST
my code is this:
`import tensorflow as tf
from tensorflow import keras
fashion_mnist = keras.datasets.fashion_mnist
(X_train_full, y_train_full), (X_test, y_test) = fashion_mnist.load_data()
X_valid, X_train = X_train_full[:5000] / 255.0, X_train_full[5000:] / 255.0
y_valid, y_train = y_train_full[:5000], y_train_full[5000:]
class_names = ["T-shirt/top", "Trouser", "Pullover", "Dress", "Coat", "Sandal", "Shirt", "Sneaker", "Bag", "Ankle boot"]
#CONSTRUINDO A REDE NEURAL
model = keras.models.Sequential()
model.add(keras.layers.Flatten(input_shape=[28, 28]))
model.add(keras.layers.Dense(300, activation="relu"))
model.add(keras.layers.Dense(100, activation="relu"))
model.add(keras.layers.Dense(10, activation="softmax"))
model.compile(loss="sparse_categorical_crossentropy", optimizer="sgd", metrics=["accuracy"])
history = model.fit(X_train, y_train, epochs=30, validation_data=(X_valid, y_valid))
model.evaluate(X_test, y_test)`
My output of this evaluate is this
313/313 [==============================] – 1s 3ms/step – loss: 68.7269 – accuracy: 0.8385
[68.72686004638672, 0.8385000228881836]
After the .fit method i got this result:
Epoch 30/30
1719/1719 [==============================] – 9s 5ms/step – loss: 0.2115 – accuracy: 0.9236 – val_loss: 0.2171 – val_accuracy: 0.9209
I am still learning and I don’t know what to do in order to fix this, also I don’t know where I could have gone Wrong…
Eduardo Bianucci Barcelona is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.