2

I need pretrained ResNet101 in Keras but Python gives me error. In the documentation they write

keras.applications.resnet.ResNet101(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)

(https://keras.io/applications/) but when I import ResNet101 Python gives the error

AttributeError: module 'keras.applications' has no attribute 'resnet' 

Moreover, I need the features calculated before the "pooling" layer, for example using VGG16 I'd do this:

myModel = Model(baseModel.input, baseModel.layers[-2].output)

How can I obtain them using ResNet? Thanks

solopiu
  • 718
  • 1
  • 9
  • 28

2 Answers2

1

The error is in your Keras version:

https://stackoverflow.com/a/54730330/9110938

Feature Extraction

Last two layers of ResNet-101 are global average pooling and fully-connected layers. Because of that:

myModel.layers[-1].output # output of the FC layer
myModel.layers[-2].output # output of the global average pooling layer
flip flop
  • 128
  • 5
0

Try this one

keras.applications.ResNet101(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)
  • Hello and welcome to Stack overflow. Don't just post code, but maybe try to explain in a few words why you think your answer solves the problem. – Ente Jul 23 '20 at 06:44