sunyilgdx / SIFRank_zh

Keyphrase or Keyword Extraction 基于预训练模型的中文关键词抽取方法(论文SIFRank: A New Baseline for Unsupervised Keyphrase Extraction Based on Pre-trained Language Model 的中文版代码)
420 stars 78 forks source link

运行时出现报错 #6

Closed ScottishFold007 closed 4 years ago

ScottishFold007 commented 4 years ago

ValueError: could not broadcast input array from shape (3,41,1024) into shape (3)

image

sunyilgdx commented 4 years ago

修复了word_emb_elmo.py中elmo_embedding的长度问题,请尝试更新一下这个文件

增加了以下代码

max_len = max([len(sent) for sent in sents_tokened])
elmo_embedding = [np.pad(emb, pad_width=((0,0),(0,max_len-emb.shape[1]),(0,0)) , mode='constant') for emb in elmo_embedding]