Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: forward() got an unexpected keyword argument 'heterograph' #3

Open
FightingEveryDay0 opened this issue Jul 6, 2023 · 10 comments

Comments

@FightingEveryDay0
Copy link

When testing, I encountered the following error and I suspect that the generate() function is missing. How can I resolve this?
Thank you very much!

LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1,2,3]
Testing: 0it [00:00, ?it/s]Traceback (most recent call last):
  File "hgsum.py", line 646, in <module>
    test(args)
  File "hgsum.py", line 558, in test
    trainer.test(model, test_dataloader)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 904, in test
    return self._call_and_handle_interrupt(self._test_impl, model, dataloaders, ckpt_path, verbose, datamodule)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 682, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 947, in _test_impl
    results = self._run(model, ckpt_path=self.tested_ckpt_path)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1193, in _run
    self._dispatch()
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1268, in _dispatch
    self.training_type_plugin.start_evaluating(self)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 206, in start_evaluating
    self._results = trainer.run_stage()
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1279, in run_stage
    return self._run_evaluate()
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1327, in _run_evaluate
    eval_loop_results = self._evaluation_loop.run()
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/loops/base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 109, in advance
    dl_outputs = self.epoch_loop.run(dataloader, dataloader_idx, dl_max_batches, self.num_dataloaders)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/loops/base.py", line 145, in run
    self.advance(*args, **kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 123, in advance
    output = self._evaluation_step(batch, batch_idx, dataloader_idx)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 211, in _evaluation_step
    output = self.trainer.accelerator.test_step(step_kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 244, in test_step
    return self.training_type_plugin.test_step(*step_kwargs.values())
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 222, in test_step
    return self.model.test_step(*args, **kwargs)
  File "hgsum.py", line 438, in test_step
    return self.validation_step(batch, batch_idx)
  File "hgsum.py", line 364, in validation_step
    result_batch = self.compute_rouge_batch(input_ids_source, tgt, heterograph_source, words_positions_source,
  File "hgsum.py", line 251, in compute_rouge_batch
    generated_ids = self.model.generate(
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/transformers/generation_utils.py", line 1181, in generate
    model_kwargs = self._prepare_encoder_decoder_kwargs_for_generation(
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/transformers/generation_utils.py", line 525, in _prepare_encoder_decoder_kwargs_for_generation
    model_kwargs["encoder_outputs"]: ModelOutput = encoder(**encoder_kwargs)
  File "/home/wangyiting/anaconda3/envs/hgsum/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
TypeError: forward() got an unexpected keyword argument 'heterograph'
Testing:   0%|          | 0/50 [00:04<?, ?it/s]
@liude12
Copy link

liude12 commented Jul 7, 2023

Hello, I also encountered the following problems in the training stage. Did you run through the training stage?

image

@liude12
Copy link

liude12 commented Jul 9, 2023

hello,I also have the same problem,Did you solve it?

@robot-2233
Copy link

wait,you guys fixed the 'utils' problem ?
image
I can't find that folder,how can I solve it?

@oaimli
Copy link
Owner

oaimli commented Jul 19, 2023

wait,you guys fixed the 'utils' problem ? image I can't find that folder,how can I solve it?

Sorry about the confusion, utils have been uploaded.

@oaimli
Copy link
Owner

oaimli commented Jul 19, 2023

Sorry, I haven't encountered these problems. Please try with the same requirements.

@liude12
Copy link

liude12 commented Jul 20, 2023

I use the same requirements, but still encounter these problems , I suspect the problem is the data, can you provide some data samples.
raceback (most recent call last): | 0/30 [00:00<?, ?it/s]
File "hgsum.py", line 573, in
train(args)
File "hgsum.py", line 456, in train
trainer.fit(model, train_dataloader, valid_dataloader)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 697, in fit
self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl
results = self._run(model, ckpt_path=self.ckpt_path)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run
results = self._run_stage()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage
return self._run_train()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1283, in _run_train
self.fit_loop.run()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run
self.advance(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/fit_loop.py", line 271, in advance
self._outputs = self.epoch_loop.run(self._data_fetcher)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 201, in run
self.on_advance_end()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 241, in on_advance_end
self._run_validation()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 299, in _run_validation
self.val_loop.run()
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run
self.advance(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance
dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run
self.advance(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 143, in advance
output = self._evaluation_step(**kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 240, in _evaluation_step
output = self.trainer._call_strategy_hook(hook_name, *kwargs.values())
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1704, in _call_strategy_hook
output = fn(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/strategies/strategy.py", line 370, in validation_step
return self.model.validation_step(*args, **kwargs)
File "hgsum.py", line 309, in validation_step
sents_positions_source, docs_positions_source, batch_idx)
File "hgsum.py", line 226, in compute_rouge_batch
docs_positions_source=docs_positions_source,
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/transformers/generation_utils.py", line 1340, in generate
inputs_tensor, model_kwargs, model_input_name
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/transformers/generation_utils.py", line 583, in _prepare_encoder_decoder_kwargs_for_generation
model_kwargs["encoder_outputs"]: ModelOutput = encoder(**encoder_kwargs)
File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
TypeError: forward() got an unexpected keyword argument 'heterograph'
Epoch 4: 100%|██████████| 30/30 [00:30<00:00, 1.00s/it, loss=3.8, v_num=3]

@robot-2233
Copy link

Sorry, I haven't encountered these problems. Please try with the same requirements.

Can you post the address of the download data, I can't find it
tks a lot

@yangjenhao
Copy link

@FightingEveryDay0 @liude12 @robot-2233
Hello, I also have the same problem.

TypeError: forward() got an unexpected keyword argument 'heterograph'

Did you solve it?

@robot-2233
Copy link

No, actually I gave up :(

@ashleydDeng
Copy link

您好,我在训练阶段也遇到了以下问题。训练阶段你跑完了吗?

图像

I use the same requirements, but still encounter these problems , I suspect the problem is the data, can you provide some data samples. raceback (most recent call last): | 0/30 [00:00<?, ?it/s] File "hgsum.py", line 573, in train(args) File "hgsum.py", line 456, in train trainer.fit(model, train_dataloader, valid_dataloader) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 697, in fit self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 735, in _fit_impl results = self._run(model, ckpt_path=self.ckpt_path) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1166, in _run results = self._run_stage() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1252, in _run_stage return self._run_train() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1283, in _run_train self.fit_loop.run() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/fit_loop.py", line 271, in advance self._outputs = self.epoch_loop.run(self._data_fetcher) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 201, in run self.on_advance_end() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 241, in on_advance_end self._run_validation() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 299, in _run_validation self.val_loop.run() File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 155, in advance dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.advance(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 143, in advance output = self._evaluation_step(**kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 240, in _evaluation_step output = self.trainer._call_strategy_hook(hook_name, *kwargs.values()) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1704, in _call_strategy_hook output = fn(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/pytorch_lightning/strategies/strategy.py", line 370, in validation_step return self.model.validation_step(*args, **kwargs) File "hgsum.py", line 309, in validation_step sents_positions_source, docs_positions_source, batch_idx) File "hgsum.py", line 226, in compute_rouge_batch docs_positions_source=docs_positions_source, File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/transformers/generation_utils.py", line 1340, in generate inputs_tensor, model_kwargs, model_input_name File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/transformers/generation_utils.py", line 583, in _prepare_encoder_decoder_kwargs_for_generation model_kwargs["encoder_outputs"]: ModelOutput = encoder(**encoder_kwargs) File "/home/tankaiwen/anaconda3/envs/hgsum12/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'heterograph' Epoch 4: 100%|██████████| 30/30 [00:30<00:00, 1.00s/it, loss=3.8, v_num=3]

Have you successfully reproduced it? I am a beginner and am very interested in this field. May I ask you for the details of the reproduction? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants