在凯拉斯(Keras)中预处理的Resnet101在哪里以及如何获得原始特征



我需要在Keras中验证的Resnet101,但Python给了我错误。在文档中,他们写

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

(https://keras.io/applications/(但是当我导入resnet101时,python给出了错误

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

此外,我需要在"合并"层之前计算出的功能,例如使用VGG16,我要这样做:

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

如何使用Resnet获得它们?谢谢

错误在您的keras版本中:

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

功能提取

RESNET-101的最后两层是全球平均合并和完全连接的层。因此:

myModel.layers[-1].output # output of the FC layer
myModel.layers[-2].output # output of the global average pooling layer

尝试这个

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

最新更新