I created this function to print the model, and mark the trainable/frozen modules:
def get_model_desc(model):
network_desc=""
for name, p in model.state_dict().items():
#p.requires_grad=True
frozen= " ·t· " if p.requires_grad else " [F] "
network_desc_spaces=" "*(55-len(name))
network_desc+=f"{name} {network_desc_spaces} {frozen} {list(p.size())}\n"
return network_desc
print(get_model_desc(model))
It shows al the parameters as frozen, but they musn’t be frozen.
I must be missing something, because there are modules whose parameters I have explicitly assigned as requires_grad=True
Also, I uncommented without success the line p.requires_grad=True