簡體   English   中英

Keras 中預訓練的 ResNet101 在哪里以及如何獲取原始特征?

[英]Where is pretrained ResNet101 in Keras and how obtain raw feature?

我需要在 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM