I am working on a multimodal classifier with images and text. I have developed and succesfully two models, one is a CNN for images and the other is a BERT-based model for text. The last layer of both models is a Dense with n units and softmax activation (where n is the number of classes). Keras provides different merging layers for combining the output vectors of these models (https://keras.io/api/layers/merging_layers/) and then it is possible to create a new network, but my question is: is there a better way to combine the decisions of the single models? Maybe to weight the values inside the vectors based on some criterion? Currently I have developed my model with a simple concatenation layer like this:
image_side = images_model(image_input)
text_side = text_model(text_input)
# Concatenation
merged = layers.Concatenate(name='Concatenation')([image_side, text_side])
merged = layers.Dense(128, activation = 'relu', name='Dense_128')(merged)
merged = layers.Dropout(0.2)(merged)
output = layers.Dense(nClasses, activation='softmax', name = "class")(merged)
Thank you in advance!