Skip to content

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

Open
AliceSum wants to merge 2 commits into
rasbt:mainfrom
AliceSum:main
Open

Pre-train notebook sets requires_grad = True for ReLU rather than the Linear layer.#3
AliceSum wants to merge 2 commits into
rasbt:mainfrom
AliceSum:main

Conversation

@AliceSum

@AliceSum AliceSum commented Jun 25, 2021

Copy link
Copy Markdown

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 <777JonathanSum@gmail.com>
…available() else 'cpu')"

I used cuda 0 because I only have one gpu.

Signed-off-by: Jonathan Sum <777JonathanSum@gmail.com>
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