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.

TypeError: add_() received an invalid combination of arguments - got (complex, Tensor)

See original GitHub issue

I have git checkout d1ec858, but after completing 40000 steps, then error happened.

INFO     step:40000 G_lr:0.000000 G_loss:113.60744(mc:0.13908 pixelwise:113.43781 pairwise:0.00256) D_lr:0.000000 D_loss:0.01955
Traceback (most recent call last):
  File "train_and_eval.py", line 25, in <module>
    model.optimize_parameters()
  File "/home/shine/文档/structure_knowledge_distillation/networks/kd_model.py", line 171, in optimize_parameters
    self.G_solver.step()
  File "/home/shine/anaconda3/envs/wangnan/lib/python3.6/site-packages/torch/optim/sgd.py", line 107, in step
    p.data.add_(-group['lr'], d_p)
TypeError: add_() received an invalid combination of arguments - got (complex, Tensor), but expected one of:
 * (Tensor other, Number alpha)
      didn't match because some of the arguments have invalid types: (complex, Tensor)
 * (Number other, Number alpha)
      didn't match because some of the arguments have invalid types: (complex, Tensor)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
wl082013commented, Aug 11, 2020

I have git checkout d1ec858, but after completing 40000 steps, then error happened.

INFO     step:40000 G_lr:0.000000 G_loss:113.60744(mc:0.13908 pixelwise:113.43781 pairwise:0.00256) D_lr:0.000000 D_loss:0.01955
Traceback (most recent call last):
  File "train_and_eval.py", line 25, in <module>
    model.optimize_parameters()
  File "/home/shine/文档/structure_knowledge_distillation/networks/kd_model.py", line 171, in optimize_parameters
    self.G_solver.step()
  File "/home/shine/anaconda3/envs/wangnan/lib/python3.6/site-packages/torch/optim/sgd.py", line 107, in step
    p.data.add_(-group['lr'], d_p)
TypeError: add_() received an invalid combination of arguments - got (complex, Tensor), but expected one of:
 * (Tensor other, Number alpha)
      didn't match because some of the arguments have invalid types: (complex, Tensor)
 * (Number other, Number alpha)
      didn't match because some of the arguments have invalid types: (complex, Tensor)

Exactly the same problem with you

0reactions
lmunancommented, Aug 12, 2020

Although there was an error in the end, the final evaluation had a good performance. Now I want to use the official resnet18-imagenet for pretrain, and then I encountered the same problem #20 . I replace conv1-3x3 with 7x7 to load the pretrain. Then the following problem appeared.

Traceback (most recent call last):
  File "train_and_eval.py", line 19, in <module>
    model = NetModel(args)
  File "/home/mist/structure_knowledge_distillation/networks/kd_model.py", line 58, in __init__
    load_S_model(args, student, False)
  File "/home/mist/structure_knowledge_distillation/utils/utils.py", line 103, in load_S_model
    model.load_state_dict(new_params)
  File "/home/mist/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:
        size mismatch for layer1.0.conv1.weight: copying a param of torch.Size([64, 128, 3, 3]) from checkpoint, where the shape is torch.Size([64, 64, 3, 3]) in current model.

Me too have the same problem with you. Did you solve it?

I did not use the official pre-trained model, I downloaded the pre-trained model from here. No error was reported, but the final result has not been seen yet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytorch TypeError: eq() received an invalid combination of ...
item() TypeError: eq() received an invalid combination of arguments - got (numpy.ndarray), but expected one of: * (Tensor other) didn't match ...
Read more >
multidim operators · Issue #9703 · pytorch/pytorch - GitHub
TypeError : std() received an invalid combination of arguments - got (Tensor, tuple), but expected one of: > * (Tensor input, bool unbiased) ......
Read more >
TypeError: new() received an invalid combination of arguments
Tensor (out_features, in_features)) TypeError: new() received an invalid combination of arguments - got (Tensor, int), but expected one of: ...
Read more >
maisteru/01-tensor-operations - Jovian
Collaborate with maisteru on 01-tensor-operations notebook. ... 5 print(output) TypeError: ge() received an invalid combination of arguments - got (Tensor, ...
Read more >
TypeError: eq received an invalid combination of arguments
LongTensor ), but expected one of … So finally I changed this line to: targs = torch.from_numpy(targs).cuda(). To get this tensor on 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