I'm trying to build a simple binary image classifier. Initially, my data looked like this
X_train.shape: (1421, 128, 128, 3)
X_test.shape : (356, 128, 128, 3)
y_train.shape: (1421,)
y_test.shape : (356,)
tried to reshape data with
X_train = X_train.reshape(-1, img_size, img_size, 3)
X_test = X_test.reshape(-1, img_size, img_size, 3)
y_train = y_train.reshape(-1, 1)
y_test = y_test.reshape(-1, 1)
and result updated to
X_train.shape: (1421, 128, 128, 3)
X_test.shape : (356, 128, 128, 3)
y_train.shape: (1421, 1)
y_test.shape : (356, 1)
model
model = Sequential([
Dense(64, activation='relu', input_shape=(X_train[0].shape)),
Dense(32, activation='relu'),
Dense(32),
Dense(1, activation='sigmoid')
])
early_stopping = keras.callbacks.EarlyStopping(
patience=10,
min_delta=0.001,
restore_best_weights=True,
)
history = model.fit(
X_train, y_train,
validation_data=(X_test, y_test),
batch_size=512,
epochs=10,
callbacks=[early_stopping],
verbose=2
)
and got the error
ValueError: logits and labels must have the same shape ((None, 128, 128, 1) vs (None, 1))