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

error: 'KGSFModel' object has no attribute 'module' #61

Closed
user-AC opened this issue Nov 11, 2022 · 5 comments
Closed

error: 'KGSFModel' object has no attribute 'module' #61

user-AC opened this issue Nov 11, 2022 · 5 comments

Comments

@user-AC
Copy link

user-AC commented Nov 11, 2022

Hi, thanks for sharing such a awsome project.

I have run a benchmark for the TG-ReDial dataset using KGSF. However, something went wrong with the code.

This is the cmd I used and all configurations are set to default.

python run_crslab.py --config config/crs/kgsf/tgredial.yaml --gpu 0

After pretrain 0-40 epochs and train recommendation epoch 0-19, it gives the following relsult:

2022-11-11 15:14:44.522 | INFO     | crslab.system.kgsf:train_recommender:147 - [Test]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████| 9000/9000 [00:00<00:00, 11171.52it/s]
2022-11-11 15:14:45.329 | INFO     | crslab.data.dataloader.base:get_data:54 - [Finish dataset process before batchify]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 18/18 [00:02<00:00,  8.21it/s]
2022-11-11 15:14:47.564 | INFO     | crslab.evaluator.standard:report:98 - 
     hit@1  hit@10  hit@50  info_loss   mrr@1  mrr@10  mrr@50  ndcg@1  ndcg@10  ndcg@50  rec_loss
   .005348  .03342  .08467      .6105 .005348  .01204  .01424 .005348   .01701   .02798     12.01

But when the next do train conversation epoch, something went wrong with the code, i.e.,

Traceback (most recent call last):
  File "run_crslab.py", line 43, in <module>
    run_crslab(config, args.save_data, args.restore_data, args.save_system, args.restore_system, args.interact,
  File "/root/autodl-tmp/csrexp/CRSLab-main/crslab/quick_start/quick_start.py", line 73, in run_crslab
    CRS.fit()
  File "/root/autodl-tmp/csrexp/CRSLab-main/crslab/system/kgsf.py", line 186, in fit
    self.train_conversation()
  File "/root/autodl-tmp/csrexp/CRSLab-main/crslab/system/kgsf.py", line 158, in train_conversation
    self.model.module.freeze_parameters()
  File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 771, in __getattr__
    raise ModuleAttributeError("'{}' object has no attribute '{}'".format(
torch.nn.modules.module.ModuleAttributeError: 'KGSFModel' object has no attribute 'module'

I hope you can take any time to reply to me, thank you very much!

@txy77
Copy link
Collaborator

txy77 commented Nov 14, 2022 via email

@user-AC
Copy link
Author

user-AC commented Nov 14, 2022

Thanks for your reply and look forward to your fix~

@wxl1999 wxl1999 closed this as completed Nov 14, 2022
@jotline
Copy link

jotline commented Nov 15, 2022

any update here?

Thanks for your reply and look forward to your fix~

change
self.model.module.freeze_parameters()
to
self.model.freeze_parameters()

Can fix this error

@txy77
Copy link
Collaborator

txy77 commented Nov 15, 2022

Yes!

@user-AC
Copy link
Author

user-AC commented Nov 16, 2022

Thanks!

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

4 participants