LeeSureman / Flat-Lattice-Transformer

code for ACL 2020 paper: FLAT: Chinese NER Using Flat-Lattice Transformer
1k stars 178 forks source link

代码运行错误 #40

Closed kevinuserdd closed 3 years ago

kevinuserdd commented 3 years ago

File "../V0/modules.py", line 93, in forward pe_ss = self.pe_ss[(pos_ss).view(-1)+self.max_seq_len].view(size=[batch,max_seq_len,max_seq_len,-1]) IndexError: index 363 is out of bounds for dimension 0 with size 351

yangluojun commented 3 years ago

File "../V0/modules.py", line 93, in forward pe_ss = self.pe_ss[(pos_ss).view(-1)+self.max_seq_len].view(size=[batch,max_seq_len,max_seq_len,-1]) IndexError: index 363 is out of bounds for dimension 0 with size 351

和max_seq_len大小有关,作者训练的时候max_seq_len取为训练集和测试集中最大的句子长度,max_seq_len被用于位置向量的编码。如果预测的句子长度超过max_seq_len + 1 的时候就会出错。建议调整flat_main.py中的max_seq_len,并且控制预测句子的长度。

lvjiujin commented 2 years ago

File "../V0/modules.py", line 93, in forward pe_ss = self.pe_ss[(pos_ss).view(-1)+self.max_seq_len].view(size=[batch,max_seq_len,max_seq_len,-1]) IndexError: index 363 is out of bounds for dimension 0 with size 351

和max_seq_len大小有关,作者训练的时候max_seq_len取为训练集和测试集中最大的句子长度,max_seq_len被用于位置向量的编码。如果预测的句子长度超过max_seq_len + 1 的时候就会出错。建议调整flat_main.py中的max_seq_len,并且控制预测句子的长度。

我想问下,这里(pos_ss).view(-1)+self.max_seq_len 有什么特殊含义吗?