Reputation: 775
I'm trying to classify images whether they're cats,dogs or pandas. the data contains all of images (cats + dogs + pandas) and the labels contains the labels of them but somehow when i fit the data to the model, the val_loss
and val_accuracy
does not show up, the only metrics shown in each epochs are loss
and accuracy
. I have no clue why it's not showing up but i have feeling that it's because i don't pass validation_data
so i passed X_test.all()
into validation_data
but the val_loss
and val_accuracy
still does not show up, what should i do?
data = np.array(data, dtype="float") / 255.0
labels = np.array(labels)
X_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.2)
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (2,2), activation = 'relu', input_shape= (height, width, n_channels)),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Conv2D(64,(2,2), activation= 'relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Conv2D(128,(2,2), activation= 'relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Conv2D(256,(2,2), activation= 'relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation= 'relu'),
tf.keras.layers.Dense(3, activation= 'softmax')
])
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
y_train = np_utils.to_categorical(y_train, 3)
model.fit(X_train, y_train, batch_size=32, epochs=25, verbose=1)
Upvotes: 2
Views: 7449
Reputation: 2782
you forget to convert y_test variable to categorical type. Add this line,
y_test = np_utils.to_categorical(y_test , 3)
Upvotes: 1
Reputation: 87
You forgot to input validation test in your model fit.
model.fit(X_train, y_train, batch_size=32, epochs=25, verbose=1, validation_data=(X_test,y_test))
Upvotes: 5