-
Notifications
You must be signed in to change notification settings - Fork 78
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 #23
Comments
同问 |
Traceback (most recent call last): |
可否产看一下是否是相似问题issue |
需要同时修改哈工大的elmoformanylangs源码中的elmo.py就能解决 |
需要同时修改哈工大的elmoformanylangs源码中的elmo.py就能解决 |
2022-01-10 17:05:17,709 INFO: char embedding size: 6169
2022-01-10 17:05:17,918 INFO: word embedding size: 71222
2022-01-10 17:05:21,442 INFO: Model(
(token_embedder): ConvTokenEmbedder(
(word_emb_layer): EmbeddingLayer(
(embedding): Embedding(71222, 100, padding_idx=3)
)
(char_emb_layer): EmbeddingLayer(
(embedding): Embedding(6169, 50, padding_idx=6166)
)
(convolutions): ModuleList(
(0): Conv1d(50, 32, kernel_size=(1,), stride=(1,))
(1): Conv1d(50, 32, kernel_size=(2,), stride=(1,))
(2): Conv1d(50, 64, kernel_size=(3,), stride=(1,))
(3): Conv1d(50, 128, kernel_size=(4,), stride=(1,))
(4): Conv1d(50, 256, kernel_size=(5,), stride=(1,))
(5): Conv1d(50, 512, kernel_size=(6,), stride=(1,))
(6): Conv1d(50, 1024, kernel_size=(7,), stride=(1,))
)
(highways): Highway(
(_layers): ModuleList(
(0): Linear(in_features=2048, out_features=4096, bias=True)
(1): Linear(in_features=2048, out_features=4096, bias=True)
)
)
(projection): Linear(in_features=2148, out_features=512, bias=True)
)
(encoder): ElmobiLm(
(forward_layer_0): LstmCellWithProjection(
(input_linearity): Linear(in_features=512, out_features=16384, bias=False)
(state_linearity): Linear(in_features=512, out_features=16384, bias=True)
(state_projection): Linear(in_features=4096, out_features=512, bias=False)
)
(backward_layer_0): LstmCellWithProjection(
(input_linearity): Linear(in_features=512, out_features=16384, bias=False)
(state_linearity): Linear(in_features=512, out_features=16384, bias=True)
(state_projection): Linear(in_features=4096, out_features=512, bias=False)
)
(forward_layer_1): LstmCellWithProjection(
(input_linearity): Linear(in_features=512, out_features=16384, bias=False)
(state_linearity): Linear(in_features=512, out_features=16384, bias=True)
(state_projection): Linear(in_features=4096, out_features=512, bias=False)
)
(backward_layer_1): LstmCellWithProjection(
(input_linearity): Linear(in_features=512, out_features=16384, bias=False)
(state_linearity): Linear(in_features=512, out_features=16384, bias=True)
(state_projection): Linear(in_features=4096, out_features=512, bias=False)
)
)
)
Model loaded succeed
2022-01-10 17:05:24,990 INFO: 1 batches, avg len: 77.5
Traceback (most recent call last):
File "/Users/hellozhang/Desktop/dj/SIFRank_关键词提取/test/test.py", line 21, in
keyphrases = SIFRank(text, SIF, zh_model, N=5,elmo_layers_weight=elmo_layers_weight)
File "/Users/hellozhang/Desktop/dj/SIFRank_关键词提取/model/method.py", line 179, in SIFRank
sent_embeddings, candidate_embeddings_list = SIF.get_tokenized_sent_embeddings(text_obj,if_DS=if_DS,if_EA=if_EA)
File "/Users/hellozhang/Desktop/dj/SIFRank_关键词提取/embeddings/sent_emb_sif.py", line 48, in get_tokenized_sent_embeddings
elmo_embeddings = self.word_embeddor.get_tokenized_words_embeddings(tokens_segmented)
File "/Users/hellozhang/Desktop/dj/SIFRank_关键词提取/embeddings/word_emb_elmo.py", line 29, in get_tokenized_words_embeddings
elmo_embedding = [np.pad(emb, pad_width=((0,0),(0,max_len-emb.shape[1]),(0,0)) , mode='constant') for emb in elmo_embedding]
File "/Users/hellozhang/Desktop/dj/SIFRank_关键词提取/embeddings/word_emb_elmo.py", line 29, in
elmo_embedding = [np.pad(emb, pad_width=((0,0),(0,max_len-emb.shape[1]),(0,0)) , mode='constant') for emb in elmo_embedding]
File "<array_function internals>", line 6, in pad
File "/Users/hellozhang/opt/anaconda3/envs/textrank/lib/python3.7/site-packages/numpy/lib/arraypad.py", line 748, in pad
pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
File "/Users/hellozhang/opt/anaconda3/envs/textrank/lib/python3.7/site-packages/numpy/lib/arraypad.py", line 519, in _as_pairs
raise ValueError("index can't contain negative values")
ValueError: index can't contain negative values
请问 这个问题怎么处理啊
The text was updated successfully, but these errors were encountered: