songyouwei / ABSA-PyTorch

Aspect Based Sentiment Analysis, PyTorch Implementations. 基于方面的情感分析,使用PyTorch实现。
MIT License
1.99k stars 522 forks source link

ASGCN #179

Closed WhatTong closed 3 years ago

WhatTong commented 3 years ago

报错:ValueError: index can't contain negative values 应该是tokenizer.max_seq_len-idx2graph[i].shape[0]小于0导致,但max_seq_len设置很大也没有办法解决 dependency_graph = np.pad(idx2graph[i], ((0, tokenizer.max_seq_len-idx2graph[i].shape[0]), (0, tokenizer.max_seq_len-idx2graph[i].shape[0])), 'constant')

GeneZC commented 3 years ago

能把场景报一下吗 也可以尝试用原仓库https://github.com/GeneZC/ASGCN 试试

Xiao-tengfei commented 3 years ago

我也遇到这个问题了,在计算dependency_graph 前,我对 “idx2graph[i]”做出限制:
if idx2graph[i].shape[0] > tokenizer.max_seq_len: idx2graph[i] = idx2graph[i][:tokenizer.max_seq_len, :tokenizer.max_seq_len]

GitOffice commented 3 years ago

也遇到同样的错误,目前是在cpu上运行的。训练集是1000条没问题,在6000条左右就出现这个错误。

GeneZC commented 3 years ago

@GitOffice 可能是某条数据图的预处理出了问题,可以使用原仓库 https://github.com/GeneZC/ASGCN 试试

GitOffice commented 3 years ago

@GeneZC 谢谢回复,那能否用你原仓库的dependency_graph.py替换这个库的py用呢?对于ASGCN模型来说,还有哪些文件有区别?

GeneZC commented 3 years ago

@GitOffice 预处理部分没有区别,区别主要在于后续部分,我目前还没排查出来这个repo的部分有什么问题。