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: scatter_add() missing 1 required positional arguments: "src"

See original GitHub issue

Hi Chen,

I have tried to follow your instructions exactly, but the following happens when I run the pretrained model:

loading checkpoint ckpt-0-0...
loading checkpoint ckpt-42.508549-0...
/home/arnav-gulati/.local/lib/python3.6/site-packages/torch/nn/functional.py:1374: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
  warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
Traceback (most recent call last):
  File "decode_full_model.py", line 169, in <module>
    args.max_dec_word, args.cuda)
  File "decode_full_model.py", line 87, in decode
    all_beams = abstractor(ext_arts, beam_size, diverse)
  File "/home/arnav-gulati/Documents/other_models/fast_abs_rl-master/decoding.py", line 116, in __call__
    all_beams = self._net.batched_beamsearch(*dec_args)
  File "/home/arnav-gulati/Documents/other_models/fast_abs_rl-master/model/copy_summ.py", line 125, in batched_beamsearch
    token, states, attention, beam_size)
  File "/home/arnav-gulati/Documents/other_models/fast_abs_rl-master/model/copy_summ.py", line 245, in topk_step
    source=score.contiguous().view(beam*batch, -1) * copy_prob
TypeError: scatter_add() missing 1 required positional arguments: "src"

The command I used was:

python3 decode_full_model.py --path=/home/arnav-gulati/Documents/other_models/fast_abs_rl-master --model_dir=/home/arnav-gulati/Documents/other_models/fast_abs_rl-master/pretrained/acl --beam=5 --test

and I followed your instructions on exporting the data path with: export DATA=/home/arnav-gulati/Documents/cnn-dailymail-master/finished_files/

I am not sure what causes the following line: TypeError: scatter_add() missing 1 required positional arguments: "src"

Do you have any advice on what I should do? I believe I have installed all the dependencies, but just in case you want to see them, here they are:

boto 2.49.0 boto3 1.9.171 botocore 1.12.171 bz2file 0.98 certifi 2019.6.16 chardet 3.0.4 cytoolz 0.9.0.1 docutils 0.14 futures 3.2.0 gensim 3.7.3 idna 2.8 jmespath 0.9.4 numpy 1.16.4 pip 19.1.1 protobuf 3.8.0 pyrouge 0.1.3 python-dateutil 2.8.0 requests 2.22.0 s3transfer 0.2.1 scipy 1.2.2 setuptools 41.0.1 six 1.12.0 smart-open 1.8.4 tensorboardX 1.7 toolz 0.9.0 torch 0.4.0 urllib3 1.25.3 wheel 0.33.4

Any help would be appreciated!

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
nickluijtgaardencommented, Jun 20, 2019

Hi @A-Gulati,

I am using this model in my own repository. I upgraded to PyTorch 1.1, and I remember needing to change the scatter_add code to get it working.

I changed it from:

    lp = torch.log(
            ((-copy_prob + 1) * gen_prob
            ).scatter_add(
                dim=1,
                index=extend_src.expand_as(score),
                source=score * copy_prob

to

lp = torch.log(
            ((-copy_prob + 1) * gen_prob
            ).scatter_add(
                dim=1,
                index=extend_src.expand_as(score),
                src=score * copy_prob

This made it work.

1reaction
ChenRockscommented, Jun 20, 2019

Hi, I am pretty sure the API of scatter_add is source not src as seen in your error message. Please see here

I would suggest you to try to completely remove pytorch and reinstall the 0.4.0 version. I recommend using anaconda python and use conda to install pytorch. Hope this will resolve the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Missing 1 required positional argument: 'self'
TypeError : test() missing 1 required positional argument: 'self'. When an instance method had self , then I called it directly by class...
Read more >
TypeError: missing 1 required positional argument: 'self'
The Python TypeError: missing 1 required positional argument: 'self' occurs when we call a method on the class instead of on an instance...
Read more >
"missing 1 required positional argument" - Python tracker
msg412510 ‑ (view) Author: Anders Hovmöller (Anders.Hovmöller) * Date: 2022‑02‑04 15:54 msg412511 ‑ (view) Author: Eric V. Smith (eric.smith) * Date: 2022‑02‑04 16:07 msg412514 ‑...
Read more >
TypeError: __init__() missing 1 required positional argument
here is my code: import torch import torchaudio import matplotlib.pyplot as plt import os import torch.nn as nn import soundfile as sf from ......
Read more >
TypeError: Missing required positional arguments
I have to complete this task for my class and Im stuck on this exercise because it always gives me this same error:...
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