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: function takes exactly 5 arguments (1 given)

See original GitHub issue

when i train my dataset, i got this error

Traceback (most recent call last):
  File "train_net.py", line 192, in <module>
    main()
  File "train_net.py", line 185, in main
    model = train(cfg, args.local_rank, args.distributed)
  File "train_net.py", line 86, in train
    arguments,
  File "/root/maskrcnn-benchmark-sync/tools/../maskrcnn_benchmark/engine/trainer.py", line 68, in do_train
    for iteration, (images, targets, _) in enumerate(data_loader, start_iter):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 623, in __next__
    return self._process_next_batch(batch)
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
TypeError: function takes exactly 5 arguments (1 given)

i think there is some error in dataset, i have checked my dataset , for example label,box valid…, but nothing help. so i trace the code to find the reason, i trace here, line 137 at dataloader.py

try:
                samples = collate_fn([dataset[i] for i in batch_indices])
            except Exception:
                # It is important that we don't store exc_info in a variable,
                # see NOTE [ Python Traceback Reference Cycle Problem ]
                data_queue.put((idx, ExceptionWrapper(sys.exc_info())))
            else:
                data_queue.put((idx, samples))
                del samples

i think problem is in BatchCollator, but i can not find any function need 5 arguments. one more thing, i train with batchsize 1 on one gpu look fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

20reactions
kakaluotecommented, Aug 12, 2019

solved. set num_workers to 0, useful information appeared. PIL image read crashed by non ascii char, some image filename has bad string encode.

0reactions
mattpopovichcommented, Mar 10, 2021

solved. set num_workers to 0, useful information appeared. PIL image read crashed by non ascii char, some image filename has bad string encode.

Thank you, this helped for me as well. My issue was I was wrongly trying to load a .txt file (label) as an image during training.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: TypeError: function takes exactly 5 arguments (1 given)
Hi, I just installed RAW on windows 10 using RAW-1.6.4-win64.msi installation. However I get following error immediately after starting the program:.
Read more >
Python error TypeError: function takes exactly 1 argument (5 ...
file.write() only takes one argument, a string. You've given it five instead: file.write("temperature is ", temperature, ...
Read more >
pytorch分布式训练之TypeError: function takes exactly 5 ...
执行以下脚本报错: TypeError: takes exactly 1 argument (2 given) #!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on 2017-12-18 @author ...
Read more >
TypeError: function takes exactly 5 arguments (1 given)
When loading a pristine database with several modules, I got the following error. This error subsequently causes exceptions in all the ...
Read more >
distance_from_zero() takes exactly 1 argument (0 given)
TypeError : distance_from_zero() takes exactly 1 argument (0 given) ... 5 votes. Permalink. The first error arises because the function distance_from_zero ...
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