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

ValueError: index can't contain negative values #7

Open
TJSL0715 opened this issue Jul 1, 2022 · 8 comments
Open

ValueError: index can't contain negative values #7

TJSL0715 opened this issue Jul 1, 2022 · 8 comments

Comments

@TJSL0715
Copy link

TJSL0715 commented Jul 1, 2022

您好,我用您的代码跑中文数据集出现了以下错误,请问您知道解决方案吗?
Traceback (most recent call last):
File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 281, in
main()
File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 276, in main
ins = Instructor(opt)
File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 53, in init
self.trainset = ABSADataset(opt.dataset_file['train'], tokenizer)
File "E:\Sentic-GCN-main\Sentic-GCN-main\data_utils_bert.py", line 183, in init
((0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0]),(0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0])), 'constant')
File "<array_function internals>", line 6, in pad
File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 746, in pad
pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 517, in _as_pairs
raise ValueError("index can't contain negative values")
ValueError: index can't contain negative values

进程已结束,退出代码 1

@BinLiang-NLP
Copy link
Owner

您好,我用您的代码跑中文数据集出现了以下错误,请问您知道解决方案吗? Traceback (most recent call last): File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 281, in main() File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 276, in main ins = Instructor(opt) File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 53, in init self.trainset = ABSADataset(opt.dataset_file['train'], tokenizer) File "E:\Sentic-GCN-main\Sentic-GCN-main\data_utils_bert.py", line 183, in init ((0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0]),(0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0])), 'constant') File "<array_function internals>", line 6, in pad File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 746, in pad pad_width = _as_pairs(pad_width, array.ndim, as_index=True) File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 517, in _as_pairs raise ValueError("index can't contain negative values") ValueError: index can't contain negative values

进程已结束,退出代码 1

您好,
请问跑的是什么中文数据集?
构图过程的graph id是否有负值?

@TJSL0715
Copy link
Author

TJSL0715 commented Jul 4, 2022

您好,我用您的代码跑中文数据集出现了以下错误,请问您知道解决方案吗? Traceback (most recent call last): File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 281, in main() File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 276, in main ins = Instructor(opt) File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 53, in init self.trainset = ABSADataset(opt.dataset_file['train'], tokenizer) File "E:\Sentic-GCN-main\Sentic-GCN-main\data_utils_bert.py", line 183, in init ((0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0]),(0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0])), 'constant') File "<array_function internals>", line 6, in pad File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 746, in pad pad_width = _as_pairs(pad_width, array.ndim, as_index=True) File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 517, in _as_pairs raise ValueError("index can't contain negative values") ValueError: index can't contain negative values
进程已结束,退出代码 1

您好, 请问跑的是什么中文数据集? 构图过程的graph id是否有负值?

我跑的是自己做的中文数据集,构图应该是没有负值,不过我的情感极值表用的是清华大学中文系 原博的中文情感极值表,这个极值表的范围较大应该是[-3,3]。我用这个极值表跑的glove词嵌入可以正常出结果,不过bert词嵌入就出现了上述错误。望解答,多谢!

@BinLiang-NLP
Copy link
Owner

您好,我用您的代码跑中文数据集出现了以下错误,请问您知道解决方案吗? Traceback (most recent call last): File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 281, in main() File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 276, in main ins = Instructor(opt) File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 53, in init self.trainset = ABSADataset(opt.dataset_file['train'], tokenizer) File "E:\Sentic-GCN-main\Sentic-GCN-main\data_utils_bert.py", line 183, in init ((0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0]),(0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0])), 'constant') File "<array_function internals>", line 6, in pad File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 746, in pad pad_width = _as_pairs(pad_width, array.ndim, as_index=True) File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 517, in _as_pairs raise ValueError("index can't contain negative values") ValueError: index can't contain negative values
进程已结束,退出代码 1

您好, 请问跑的是什么中文数据集? 构图过程的graph id是否有负值?

我跑的是自己做的中文数据集,构图应该是没有负值,不过我的情感极值表用的是清华大学中文系 原博的中文情感极值表,这个极值表的范围较大应该是[-3,3]。我用这个极值表跑的glove词嵌入可以正常出结果,不过bert词嵌入就出现了上述错误。望解答,多谢!

您好,是否有可能是BERT分词不对应问题?

@TJSL0715
Copy link
Author

TJSL0715 commented Jul 7, 2022

是否可以详细说明一下思路?刚入门还不太理解您说的话。

@BinLiang-NLP
Copy link
Owner

是否可以详细说明一下思路?刚入门还不太理解您说的话。

您好!
我的意思是,中文分词的结果和BERT Tokenizer的分词结果不一致。这样可能会导致矩阵溢出。
这个工作使用的是senticnet的情感得分(.py文件),senticnet5和senticnet6都适用。

@TJSL0715
Copy link
Author

多谢,回头我深入学习一下bert中文分词与词向量!

@BinLiang-NLP
Copy link
Owner

多谢,回头我深入学习一下bert中文分词与词向量!

再次感谢您的关注。如有其他问题,可以随时联系我。

@TJSL0715
Copy link
Author

TJSL0715 commented Sep 7, 2022

您好,我看到了senticnet的作者也是您的这篇论文的作者之一,请问您对senticnet中的极性强度值的构造方法及原理是否了解?
我也给您的教育邮箱发了请教邮件,如有打扰还请谅解!

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

2 participants