项目场景:
Semantic Role Labeling使用BiLSTM-crf
pytorch环境
问题描述
训练
def forward(self, x, poses, rels, sent_lengths):
mask = torch.ne(x, self.pad_index)
emissions = self.lstm_forward(x, poses, rels, sent_lengths)
return self.crflayer.decode(emissions, mask=mask)
原因分析:
pytorch-crf版本问题
解决方案:
pip install -U -i https://pypi.tuna.tsinghua.edu.cn/simple pytorch-crf==0.7.0