I am building a TensorFlow model for Binary Image Classification. I have two labels "good" and "bad" I want the model should output for each image in the data set, whether that image is good or bad and with what probability
For example if I submit 1.jpg and let's suppose it is "good" image. Then the model should predict that 1.jpg is good with 100% probability and bad with 0% probaility.
So far I have been able to come up with following
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(16, (3,3), activation='relu', input_shape=(input_shape, input_shape, 3)),
tf.keras.layers.MaxPool2D(2,2),
#
tf.keras.layers.Conv2D(32, (3,3), activation='relu'),
tf.keras.layers.MaxPool2D(2,2),
#
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPool2D(2,2),
##
tf.keras.layers.Flatten(),
##
tf.keras.layers.Dense(512, activation='relu'),
##
tf.keras.layers.Dense(1, activation='sigmoid')
])
The shape of output from the above model is 1 x 1. But I think this will not serve my purpose.
I am compiling the model in this way
model.compile(loss='binary_crossentropy',
optimizer=RMSprop(lr=0.001),
metrics=['accuracy'])
model_fit = model.fit(train_dataset,
steps_per_epoch=3,
epochs=30,
validation_data=validation_dataset)
Any help is greatly appreciated.