Skip to content
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

Extend part of the model #232

Open
haonan3 opened this issue Nov 1, 2021 · 1 comment
Open

Extend part of the model #232

haonan3 opened this issue Nov 1, 2021 · 1 comment

Comments

@haonan3
Copy link

haonan3 commented Nov 1, 2021

Hello,

I am wondering is it possible to extend part of the model, if I only want to get the batch gradient of the last several layers?

I think model = extend(model) will waste memory if only the batch gradient of the last several layers is needed.

For example, if I only want to extend the last two layers (let's say the last two layers are fc1 and fc2) of a large model, can I do something like this:

model.fc1 = extend(model.fc1)
model.fc2 = extend(model.fc2)
@f-dangel
Copy link
Owner

f-dangel commented Nov 3, 2021

Hi,

for individual gradients it is indeed sufficient to only extend the modules whose parameters you're interested in.

Best,
Felix

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

No branches or pull requests

2 participants