0
$\begingroup$

I read the architecture of the model but this is the first time I try to use it . The calculations of the features map will be different if I extract the features from the two last layers or from the last layer but does it will affect if I used it in another model.

$\endgroup$

1 Answer 1

0
$\begingroup$

Yes it will definitely affect the result. If you are going to use CNN pre-trained models for feature extraction you have to remove the last output layer. Along with that you have to remove all the densely(Fully) connected layers since those will act as ANN for processing to predict the results. We need only the features to be trained using other models like SVC, Random forest etc.

$\endgroup$
5
  • $\begingroup$ Thanks a lot for replying , but excuse me if I want these features for captioning .. will I remove the last only ? $\endgroup$ Commented Sep 23, 2021 at 0:15
  • $\begingroup$ sorry to say. last layer is just the classification layer(i mean output layer) in the pre- trained models followed by some fully connected layers, Irrespective of final output, either captioning or normal classification etc you only need the features so it is good to remove the fully connected layers as well. $\endgroup$ Commented Sep 23, 2021 at 4:53
  • $\begingroup$ Thakns. you mean like that model=Model(inputs=model.inputs,outputs=model.layers[-2].output) $\endgroup$ Commented Sep 23, 2021 at 5:03
  • $\begingroup$ Yes correct, make sure it removed all the fully connected layers using model.summary() before and after applying -2. Then sometimes -2 will remove any Average pooling layer as well, if so please add that layer at the end like. new_layer = tf.keras.layers.GlobalAveragePooling2D()(densenet_model.layers[-1].output). customized_denset = Model(densenet_model.input, new_layer) $\endgroup$ Commented Sep 23, 2021 at 5:25
  • $\begingroup$ Thanks a lot if you have a good background in captioning can you please give me your email . Thanks in advance $\endgroup$ Commented Sep 24, 2021 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.