Do not send this model to the pet store to get a dog or a cat. You have a 46% chance of getting what you wanted. This is my model. I have just resolved the image issue I was experiencing during testing, after much trial and error, mostly error. The issue was resolved by setting batch_size for test_data_gen to 50 so all 50 images were available for use. All documentation for testing data seemed to indicate that batch_size should of course be 1, since the model is seeing it once, but I digress.
Now I am stuck with a crappy model that doesn’t get more accurate no matter what I tweak. I’ve tried changing batch_size for training and validation sets, epochs, filters, steps, nothing is improving the accuracy.
Anybody have any suggestions as to what I should try next?
model = Sequential([
Conv2D(64, (5, 5), activation='relu', padding='same', strides=2, input_shape=(150, 150, 3)),
MaxPooling2D((2, 2), strides=2),
Conv2D(16, (3,3), padding='same', strides=2, activation='relu'),
MaxPooling2D((2,2), strides=2),
#Conv2D(16, (3,3), padding='same', strides=1, activation='relu'),
#MaxPooling2D((2,2), strides =1),
Flatten(),
Dense(32, activation='relu'),
Dense(2, activation='sigmoid')
])
#model.add(tf.keras.Input(shape=(IMG_HEIGHT, IMG_WIDTH, 3)))
#model.add(tf.keras.layers.Conv2D(128, (3,3), padding = 'same', strides = (2,2), activation='relu'))
#Conv2D(64, (3,3), padding = 'same', strides = (3,3), activation='relu', input_shape=(150, 150, 3)),
#MaxPooling2D((2,2), padding = 'same'),
#Conv2D(32, (3,3), padding = 'same', strides = (3,3), activation='relu'),
#MaxPooling2D((2,2), padding = 'same'),
#Conv2D(16, (3,3), padding = 'same', strides = (2,2), activation='relu'),
#MaxPooling2D((2,2), padding = 'same'),
#Flatten(),
#Dense(16, activation='relu'),
#Dense(8),
#Dense(2, activation='relu')
#])
#base_model = tf.keras.applications.MobileNetV2(input_shape=(150, 150, 3), include_top=False, weights='imagenet')
#base_model.trainable = False
#global_average_layer = tf.keras.layers.GlobalAveragePooling2D()
#prediction_layer = tf.keras.layers.Dense(2)
#model = tf.keras.Sequential([
#base_model,
#global_average_layer,
#prediction_layer
#])
print(len(model.weights))
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
#optimizer='rmsprop'
