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

training 设置报错 #87

Open
xy-derrick opened this issue Mar 24, 2024 · 3 comments
Open

training 设置报错 #87

xy-derrick opened this issue Mar 24, 2024 · 3 comments

Comments

@xy-derrick
Copy link

xy-derrick commented Mar 24, 2024

def train_recommender(self):
    if hasattr(self.rec_model, 'bert'):
        if os.environ["CUDA_VISIBLE_DEVICES"] == '-1':
            bert_param = list(self.rec_model.bert.named_parameters())
        else:
            bert_param = list(self.rec_model.module.bert.named_parameters())
        bert_param_name = ['bert.' + n for n, p in bert_param]
    else:
        bert_param = []

在这段代码中 bert_param = list(self.rec_model.module.bert.named_parameters()) 报错说 'TGRecModel' object has no attribute 'module',请问原因是?然后想问一下这个module是干嘛的

@xy-derrick xy-derrick reopened this Mar 24, 2024
@xy-derrick xy-derrick changed the title interact表现 training 设置报错 Mar 24, 2024
@ChenCyril
Copy link

我也有点奇怪...用GPU跑就报这个错,CPU跑倒是没问题emmm...

@enchantee00
Copy link

enchantee00 commented Apr 12, 2024

change
bert_param = list(self.rec_model.module.bert.named_parameters())
to
bert_param = list(self.rec_model.bert.named_parameters())

Can fix this error

@nguyenminhduc392002
Copy link

"Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/nltk/util.py", line 468, in ngrams
history.append(next(sequence))
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/kaggle/working/CRSLab-main/run_crslab.py", line 43, in
run_crslab(config, args.save_data, args.restore_data, args.save_system, args.restore_system, args.interact,
File "/kaggle/working/CRSLab-main/crslab/quick_start/quick_start.py", line 73, in run_crslab
CRS.fit()
File "/kaggle/working/CRSLab-main/crslab/system/inspired.py", line 206, in fit
self.train_conversation()
File "/kaggle/working/CRSLab-main/crslab/system/inspired.py", line 188, in train_conversation
self.step((batch), stage='conv', mode='val')
File "/kaggle/working/CRSLab-main/crslab/system/inspired.py", line 120, in step
self.conv_evaluate(pred, batch[-1])
File "/kaggle/working/CRSLab-main/crslab/system/inspired.py", line 89, in conv_evaluate
self.evaluator.gen_evaluate(p_str, [r_str])
File "/kaggle/working/CRSLab-main/crslab/evaluator/standard.py", line 80, in gen_evaluate
for token in ngrams(hyp, k):
RuntimeError: generator raised StopIteration" Can you help me fix this error?

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