question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about a module that does not required grad

See original GitHub issue

Thanks for the wonderful library!

I have one question about how to use higher.

I want to train the network with second order derivative,

but some parts of network (such as nn.Embedding ) are frozen.

something like this

net= Net()
param = filter(lambda x: x.requires_grad, model.parameters())
inner_opt = torch.optim.SGD(param, lr=1e-1)

with higher.innerloop_ctx(net, inner_opt, copy_initial_weights=False) as (fnet, diffopt):
  logits = net(batch_x)
  loss = loss_fnt(logits, batch_y)
  diffopt.step(loss)
              

but i got the error message “RuntimeError: One of the differentiated Tensors does not require grad”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
egrefencommented, Oct 25, 2019

On my to-do list for tomorrow!

0reactions
egrefencommented, Oct 25, 2019

Fixed in #11. Please re-open if this does not address your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - element 0 of tensors does not require grad and ...
I reward agent if he's correct positive 1 or not negative -1 and computate loss FUNC with predicted_action(predicted_class) and reward. But I ...
Read more >
Problem : RuntimeError: element 0 of tensors does not ...
Hi ! I am creating a ladder like autoencoder network for video prediction. I create 2 class : one for the encoder and...
Read more >
What is the use of torch.no_grad in pytorch?
Use of Torch.no_grad() : To perform inference without Gradient Calculation. To make sure there's no leak test data into the model.
Read more >
Entrance Counseling
Entrance counseling for graduate or professional students is required if you have not previously received a Direct Unsubsidized Loan or Direct PLUS Loan....
Read more >
Frequently Asked Questions (FAQs) // Graduate School ...
Frequently Asked Questions (FAQs), Graduate School, Marquette University. ... Which Marquette graduate programs are not administered by the Graduate School?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found