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.

RunTime Error from e = Variable(torch.Tensor())

See original GitHub issue

Sorry for my troubles, but why does using the e = Variable(torch.Tensor) raise RuntimeError: expected a Variable argument, but got FloatTensor in a recursive class implementation? I mean, e is already a Variable as defined on Line 77. The relevant call stack is

RuntimeError: expected a Variable argument, but got FloatTensor
> /home/robotec/catkin_ws/src/RAL2017/pyrnn/src/model.py(77)qp_layer()
     75             h = self.h.unsqueeze(0).expand(nBatch, nineq)
     76             e = Variable(torch.Tensor())
---> 77             x = QPFunction()(x, Q, p, G, h, e, e)
     78             return x
     79         self.qp_layer = qp_layer

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bamoscommented, Apr 6, 2017

Making everything Variables/Parameters should fix this issue (though let us know if not). Also something new we’ve added is that you don’t have to expand h or any other variable across the minibatch, QPFunction automatically detects that internally.

0reactions
bamoscommented, Apr 7, 2017

Great, glad things are working!

Read more comments on GitHub >

github_iconTop Results From Across the Web

one of the variables needed for gradient computation has ...
[Solved][Pytorch1.5] RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation.
Read more >
RuntimeError: one of the variables needed for gradient ...
RuntimeError : one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.LongTensor [128, 1]] ...
Read more >
RuntimeError: one of the variables needed for ... - M N – Medium
RuntimeError : one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor []], which is output 0...
Read more >
pytorch_basics
print(torch.arange(5).exp()) except RuntimeError as E: print(f"Got exception: '{E}'") tensor([ 1.0000, 2.7183, 7.3891, 20.0855, 54.5981]).
Read more >
tf.Tensor | TensorFlow v2.11.0
print(e.numpy()) [[1. 3.] [3. 7.]] In TensorFlow, tf.function s are a common way to define graph execution. A Tensor's shape (that is, the...
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