i want to fix weights which have a value of ‘zero’ in model.parameters() (model is a neural network) it means i have to freeze it in element-wise so i made a code below.
in the code, model.parameters() will be input of ‘Lparam’ and when i ran the code, i got an error like 'nonetype has no attribute ‘zero_()’
and when i try another trick like requires_grad=False, error says like, "only leaf variables can use requires_grad"
then how can i approach leaf variables to fix the zero weights in the computation graph? here is my code.

KakaoTalk_20210413_104326868878×516 67.6 KB