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: 'generator' object is not callable

See original GitHub issue

I’m getting the exception TypeError: ‘generator’ object is not callable when I train with multiple GPU’s

I’m not sure where it’s coming from, my datasets are subclasses of torchtext.data.Dataset and the data loaders are torchtext.data.BucketIterator.

What’s the easiest way of identifying what’s causing the exception?

    # create trainer
    mlflow = loggers.MLFlowLogger("Transformer")
    trainer = pl.Trainer.from_argparse_args(args, early_stop_callback=True, min_epochs=10, logger=mlflow, gpus=[0,1])

    # prepare data
    train_dataset, val_dataset = load_datasets(path=args.path, files=args.files)
    train_loader, val_loader = create_dataloaders(train_dataset, val_dataset, batch_size=args.batch_size)

    # init the model
    hparams = vars(args)
    transformer = Transformer(src_vocab=train_dataset.vocab, tgt_vocab=val_dataset.vocab, **hparams)

    # train
    trainer.fit(transformer, train_loader, val_dataloaders=val_loader)
    transformer.freeze()


Issue Analytics

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

github_iconTop GitHub Comments

1reaction
edenlightningcommented, Sep 10, 2020

@awaelchli mind taking a look?

0reactions
david-waterworthcommented, Sep 10, 2020

@awaelchli thanks for looking. I need to refactor this anyway since as I mentioned torchtext has started to deprecate their DataLoader / Dataset in place of the torch equivalents. I’ve been putting it off since they’ve not yet provided a migration path for custom datasets (frustratingly they seem to be focusing on migrating the built-in datasets using private pipeline methods - I feel they should have created a migration pathway first and then used it to migrate their datasets).

@mateuszpieniak any pointers would be useful - I need to add ‘<sos>’ and ‘<eos>’ tokens to each example and then pad each batch. Ideally, by using high-performance code someone has already thoroughly tested

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'generator' object is not callable - Stack Overflow
A parameter passed to the somefun function is then bound to the local lengen variable instead of lengths , to make it clear...
Read more >
TypeError: 'generator' object is not callable #3379 - GitHub
I'm getting the exception TypeError: 'generator' object is not callable when I train with multiple GPU's I'm not sure where it's coming from ......
Read more >
Generator Functions - Lazy Looping in Python
When the function is called, it returns a generator object. ... line 1, in <module> TypeError: 'generator' object is not callable >>> c[0]...
Read more >
Generator object not callable (sorry about the messy code)
I cant figure out how to use yield to return from a while-loop without breaking from the function. Is there anything i'm missing...
Read more >
Error occured when using sidebar - Streamlit
... and when it comes to sidebar, it suddenly can not work ,the error is TypeError: 'DeltaGenerator' object is not callable.
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