Can we use Keras model's accuracy metric for Image Captioning model?

Issue Kindly consider the following line of code. model.compile(loss=’categorical_crossentropy’, optimizer=’adam’,metrics=[‘accuracy’]) I am allowed to use metrics=[‘accuracy’] for my Image Captioning model. My model has been defined as follows: inputs1 = Input(shape=(2048,)) fe1 = Dropout(0.2)(inputs1) fe1=BatchNormalization()(fe1) fe2 = Dense(256, activation=’relu’)(fe1) inputs2

Continue reading

how to get history['val_accuracy'] from ImageDataGenerator

Issue I’m using keras.preprocessing.image.ImageDataGenerator When i fed it to model.fit like that history = model.fit( train_data_gen, epochs=EPOCHS, steps_per_epoch=steps_per_epoch, validation_data=val_data_gen, validation_freq=validation_freq, callbacks=[EarlyStopping(monitor=’val_accuracy’, patience=2)] ) it works fine, but there is no actual validation data, so my callback doesn’t work, as well

Continue reading

TensorFlow GradCAM – model.fit() – ValueError: Shapes (None, 1) and (None, 2) are incompatible

Issue As part of assignment 4, Coursera CV TF course, my code fails in model.fit() model.compile(loss=’categorical_crossentropy’,metrics= [‘accuracy’],optimizer=tf.keras.optimizers.RMSprop(lr=0.001)) # shuffle and create batches before training model.fit(train_batches,epochs=25) with error: ValueError: Shapes (None, 1) and (None, 2) are incompatible Any hint at where

Continue reading

Can flow_from_directory get train and validation data from the same directory in Keras?

Issue I got the following example from here. train_datagen = ImageDataGenerator( rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True) test_datagen = ImageDataGenerator(rescale=1./255) train_generator = train_datagen.flow_from_directory( ‘data/train’, target_size=(150, 150), batch_size=32, class_mode=’binary’) validation_generator = test_datagen.flow_from_directory( ‘data/validation’, target_size=(150, 150), batch_size=32, class_mode=’binary’) There are two separate directories for

Continue reading