-
Notifications
You must be signed in to change notification settings - Fork 66
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
您好问个问题,参数里没分类个数 #1
Comments
不需要分类个数 在'bert.py'的‘MyPro() - get_labels’里,直接把'return [0, 1]'改成你的类别名列表 |
我也能遇到了类似的问题,我把return[0,1]改成我的类别列表后,报了这个错,RuntimeError: CUDA error: device-side assert triggered。去网上查了下,是说类别的数量必须在0到n_classes之间,但是n_classes(分类个数)不知道在什么地方设置。我的类别数量有4000+个,请问有遇到类似的问题吗 |
@licheng-pro def get_labels(self):
return [str(i) for i in range(n_classes)] |
@ETCartman 没有转成label id, |
@licheng-pro 需要return是lable id,而不是label! def get_labels(self, label_path):
fo = open(label_path, 'r', encoding='utf-8')
lines = fo.readlines()
label_to_id ={}
for i, line in enumerate(lines):
label_to_id[line.strip()] = i
print(label_to_id)
fo.close()
return [str(i) for i in range(len(label_to_id))] or just: def get_labels(self, label_path):
fo = open(label_path, 'r', encoding='utf-8')
lines = fo.readlines()
fo.close()
return [str(i) for i in range(len(lines))] |
@ETCartman |
@licheng-pro 刚去看了下代码确实是:stuck_out_tongue:,不过我做2k个类别没有任何问题。 |
我已经解决了,多谢了,老哥 @ETCartman |
不过现在好像在
这一行会报如下的错误:
|
我也是这个问题,请问你解决了吗? |
@Zhaohaoran1997 在最后加上这个参数就可以
也可以参考我fork的代码:https://github.com/liuyijiang1994/bert_senta |
我改了num_labels之后程序被kill了,请问是我写得有bug还是机器性能不足?
|
@Zhaohaoran1997 看上去运行的时候已经是正常的了 也许是性能的问题 |
应该在哪添加啊,我看from_pretrained代码里没找到
The text was updated successfully, but these errors were encountered: