huggingface / neuralcoref

✨Fast Coreference Resolution in spaCy with Neural Networks
https://huggingface.co/coref/
MIT License
2.86k stars 478 forks source link

size mismatch #35

Closed memoer6 closed 5 years ago

memoer6 commented 6 years ago

Hi

Thanks very much for sharing the library. It's amazing

I think there is a size mismatch between the input features and the pre-trained weights posted on this site for the input layer

The pre-trained weights, stored in neuralcoref/weights folder of this repository, have a size of ( 1000 x 668 ) for single mentions, and ( 1000 x 1364 ) for pair mentions in layer 0

However, the dimension of input features generated for each mention is 674 per single mention, and 1370 per pair mentions, if compressed = False.

This mismatch generates an error during the evaluation process if the pre-trained weights are loaded, as shown below

Do you have the same problem?

Thanks,

`--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last)

in () 61 eval_evaluator.test_model() 62 start_time = time.time() ---> 63 eval_evaluator.build_test_file() 64 score, f1_conll, ident = eval_evaluator.get_score() 65 elapsed = time.time() - start_time ~/coding/coreference/notebook/learning/evaluator.py in build_test_file(self, out_path, remove_singleton, print_all_mentions, debug) 162 cur_m = 0 163 for sample_batched, mentions_idx, n_pairs_l in zip(self.dataloader, self.mentions_idx, self.n_pairs): --> 164 scores, max_i = self.get_max_score(sample_batched) 165 for m_idx, ind, n_pairs in zip(mentions_idx, max_i, n_pairs_l): 166 if ind < n_pairs : # the single score is not the highest, we have a match ! ~/coding/coreference/notebook/learning/evaluator.py in get_max_score(self, batch, debug) 140 mask = mask.cuda() 141 self.model.eval() --> 142 scores = self.model.forward(inputs, concat_axis=1).data 143 scores.masked_fill_(mask, -float('Inf')) 144 _, max_idx = scores.max(dim=1) # We may want to weight the single score with coref.greedyness ~/coding/coreference/notebook/learning/model.py in forward(self, inputs, concat_axis) 72 embed_words = self.drop(self.word_embeds(words).view(words.size()[0], -1)) 73 single_input = torch.cat([spans, embed_words, single_features], 1) ---> 74 single_scores = self.single_top(single_input) 75 if pairs: 76 batchsize, pairs_num, _ = ana_spans.size() ~/software/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs) 355 result = self._slow_forward(*input, **kwargs) 356 else: --> 357 result = self.forward(*input, **kwargs) 358 for hook in self._forward_hooks.values(): 359 hook_result = hook(self, input, result) ~/software/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/container.py in forward(self, input) 65 def forward(self, input): 66 for module in self._modules.values(): ---> 67 input = module(input) 68 return input 69 ~/software/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs) 355 result = self._slow_forward(*input, **kwargs) 356 else: --> 357 result = self.forward(*input, **kwargs) 358 for hook in self._forward_hooks.values(): 359 hook_result = hook(self, input, result) ~/software/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/linear.py in forward(self, input) 53 54 def forward(self, input): ---> 55 return F.linear(input, self.weight, self.bias) 56 57 def __repr__(self): ~/software/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py in linear(input, weight, bias) 833 if input.dim() == 2 and bias is not None: 834 # fused op is marginally faster --> 835 return torch.addmm(bias, input, weight.t()) 836 837 output = input.matmul(weight.t()) RuntimeError: size mismatch, m1: [1 x 674], m2: [668 x 1000] at /opt/conda/conda-bld/pytorch_1523244252089/work/torch/lib/TH/generic/THTensorMath.c:1434 `
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.