Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Naming layers and getting trainer weights #335

Answered by szha
sravanbabuiitm asked this question in Q&A
Discussion options

You must be logged in to vote

Since collect_params() returns a ParameterDict, which is a dictionary, you can add elements to it. For example:

d = net.layer1.collect_params()
d.update(net.layer2.collect_params())

As long as you don't add the embedding layer's parameter in the dictionary passed to the trainer, then it won't update. I'd still recommend setting the grad_req to null for the layers you don't intend to update so that the gradient calculation can be skipped.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by szha
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #335 on August 30, 2020 19:15.