Skip to content

Pre-train notebook sets requires_grad = True for ReLU rather than the Linear layer. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AliceSum
Copy link

@AliceSum AliceSum commented Jun 25, 2021

image

It should be Model.classifier[0].requires_grad = True because the layer at index 0 is the linear layer. Index 1 is the ReLU layer which does not have trainable parameters.

I have retrained the small VGG notebook with Model.classifier[0].requires_grad = True. The end result is kind of the same. That is test accuracy is 78%, but the training accuracy is slightly higher than the original notebook.
image

@AliceSum AliceSum changed the title Changing the classifier layer to has grad for the first linear layer … pre-train notebook sets requires_grad = True for ReLU rather than the Linear layer. Jun 25, 2021
@AliceSum AliceSum changed the title pre-train notebook sets requires_grad = True for ReLU rather than the Linear layer. Pre-train notebook sets requires_grad = True for ReLU rather than the Linear layer. Jun 25, 2021
AliceSum added 2 commits June 25, 2021 12:43
…of classifier lay, instead of the relu.

Signed-off-by: Jonathan Sum <[email protected]>
…available() else 'cpu')"

I used cuda 0 because I only have one gpu.

Signed-off-by: Jonathan Sum <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant