timm错误features_only not implemented for Vision Transformer models.

错误:

使用timm的ViT模型时

model = timm.create_model(net, pretrained=True, features_only=True)

出错:features_only not implemented for Vision Transformer models.

分析(timm作者回复):

the ViT models don't have a pyramid of spatial features in the same way that CNN models do, so it doesn't really fit the concept behind features_only=True. It's not clear whether returning (flat) feature vectors at different points in the transfomer block stack would be useful for anything. Like other networks, you can remove the head and get the last features creating model with num_classes=0 or calling model.reset_classifier(0)

使用以上方式能够获得特征,但并不是金字塔特征。

参考:"Features_only" - key missing for ViT-Models? · Issue #397 · huggingface/pytorch-image-models (github.com)

猜你喜欢

转载自blog.csdn.net/dou3516/article/details/131054283