Created
September 29, 2021 08:56
-
-
Save napoler/082bc2c4f7bb1f6772b6f73b0630ac16 to your computer and use it in GitHub Desktop.
Created with Copy to Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Model() | |
# 这里是一般情况,共享层往往不止一层,所以做一个for循环 | |
for para in model.linear1.parameters(): | |
para.requires_grad = False | |
# 假如真的只有一层也可以这样操作: | |
# model.linear1.weight.requires_grad = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment