bharathichezhiyan / Multimodal-Meme-Classification-Identifying-Offensive-Content-in-Image-and-Text

Multimodal Meme Classification: Identifying Offensive Content in Image and Text
66 stars 19 forks source link

Training image model, the val acc alwasys shows 1 #16

Open AlinaXie opened 3 years ago

AlinaXie commented 3 years ago

Hi, Because I read your paper before, I think it is an interesting topic. So I try to reproduce it. But when I train the image model, its result is very strange. The validation accuracy always shows 1. I do not whether there is a problem when I process the code. I have tried many methods but I cannot solve it. I would be appreciated if I can receive your help. Thanks.

result1 result2
harshgeek4coder commented 3 years ago

Same issue here

harshgeek4coder commented 3 years ago

Hi, Because I read your paper before, I think it is an interesting topic. So I try to reproduce it. But when I train the image model, its result is very strange. The validation accuracy always shows 1. I do not whether there is a problem when I process the code. I have tried many methods but I cannot solve it. I would be appreciated if I can receive your help. Thanks. result1 result2

@AlinaXie and @bharathichezhiyan
I somehow managed to resolve this error by refactoring the image_model function and removing GlobalAveragePooling2D(), and also, modified the image neural network to some extent. I am mentioning the code for your further reference :

def Image_Model(base_model):
  for layer in base_model.layers:
    layer.trainable = False
  x = base_model.output
  return (x)

Neural Network :

#MAIN IMAGE MODEL - II : 
def get_image_only_model():
  pre_trained_image_model_vgg16 = VGG16(include_top=False, weights='/content/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5',input_shape=(224,224) + (3,))
  base_model_loaded = Image_Model(pre_trained_image_model_vgg16)
  flatten_layer = Flatten()(base_model_loaded)
  dropout_layer = Dropout(0.5)(flatten_layer)
  image_pred_layer = Dense(1, activation='sigmoid')(dropout_layer)
  image_only_model = Model(inputs = [pre_trained_image_model_vgg16.input], outputs = image_pred_layer)

  return image_only_model

This worked with showing somewhat better learning for VGG16 Model :

image

keyuchen21 commented 2 years ago

@harshgeek4coder I followed your instruction but still get val_accuracy of 1, could you share your code?

Adrillanos commented 2 years ago

Hi, i have a similar issue, the val_acc always show 0.000, any advice?