Thanks for your reply,
First,
print(list(self.model.children()))

[Sequential(
  (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
   .....
  ), Linear(in_features=512, out_features=7, bias=True)]

For two term in the list, it need to choose the Sequential term.
Second, the optimizer only update the input because I don’t want to train the model.
I want to visualize convolutional features, and train the input that can activate the selected filter.
reference 6
I remove .detach() and it work. Thanks a lot!