keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 910 forks source link

The shape of the Output of ResNet50 's Last-1 layer changed. #50

Closed kesarianubhav closed 5 years ago

kesarianubhav commented 5 years ago

Shape of Each Extracted Feature (1, 7, 7, 2048) preprocessing input for rnn Traceback (most recent call last): File "main.py", line 88, in for i in extracted_features_train] File "main.py", line 88, in for i in extracted_features_train] File "/home/anu/Desktop/btp/implementation/rnn_backend.py", line 42, in preprocess_input_rnn tensor = tensor.reshape((n_time_steps, n_inputs)) ValueError: cannot reshape array of size 100352 into shape (32,64)

I am using pretrained ResNet50 Model for Feature Extraction. Earlier the Shape of the Feature Vector which I was getting from the Last -1 layer was of shape (1,1,1,2048). But Now It seems that its shape is changed to (1,7,7,2048) .

taehoonlee commented 5 years ago

@kesarianubhav, for the consistency over all the models here, the bottleneck size of ResNet50 has been changed from 1x1 to 7x7. Please refer to the table about bottleneck sizes.

yasindagasan commented 4 years ago

just add pooling='avg' to get the 2048 feature vector

model = ResNet50(weights='imagenet', include_top=False,pooling='avg')