Hello,
I am getting an error when trying to create a feature extractor using the create_feature_extractor()
function (from torchvision.models.feature_extraction import create_feature_extractor
). What I wanna do is:
- I create a model using timm library like this
model = timm.create_model('maxvit_xlarge_tf_512.in21k_ft_in1k', pretrained=True)
- I take attention layers
attention_layer_names = []
layer_name = 'attn_drop'
for name, module in model.named_modules():
if layer_name in name:
attention_layer_names.append(name)
- Try to create a feature extractor
feature_extractor = create_feature_extractor(model, return_nodes=attention_layer_names)
I am getting this error
TraceError: symbolically traced variables cannot be used as inputs to control flow
How could I solve it?