EADST

Pytorch: Freeze layers to Finetune the Model

Pytorch: Freeze layers to Finetune the Model.

for k, v in model.named_parameters():
    print(k) # check the layer name
for k, v in model.named_parameters():
    if k in ["last.weight", "last.bias"]: # freeze the layer with the given name list
        v.requires_grad = True
    else:
        v.requires_grad = False
       
      
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
站点统计

本站现有博文242篇,共被浏览290904

本站已经建立1780天!

热门文章
文章归档
回到顶部