huggingface / neuralcoref

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

Size mismatch error #269

Open firasfrikha opened 4 years ago

firasfrikha commented 4 years ago

Hello everyone, i'm trying to train neuralcoref for french language. After training the model, i add it to the pipeline but when i execute this command:

doc = nlp(u"je suis firas")

I get the following error


---------------------------------------------------------------------------
ShapeMismatchError                        Traceback (most recent call last)
<ipython-input-31-0862bb3d76d3> in <module>
----> 1 doc = nlp(u"je suis firas")

~/.conda/envs/coref2/lib/python3.8/site-packages/spacy/language.py in __call__(self, text, disable, component_cfg)
    437             if not hasattr(proc, "__call__"):
    438                 raise ValueError(Errors.E003.format(component=type(proc), name=name))
--> 439             doc = proc(doc, **component_cfg.get(name, {}))
    440             if doc is None:
    441                 raise ValueError(Errors.E005.format(name=name))

neuralcoref.pyx in neuralcoref.neuralcoref.NeuralCoref.__call__()

neuralcoref.pyx in neuralcoref.neuralcoref.NeuralCoref.predict()

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/model.py in __call__(self, x)
    165             Must match expected shape
    166         """
--> 167         return self.predict(x)
    168 
    169     def pipe(self, stream, batch_size=128):

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/feed_forward.py in predict(self, X)
     38     def predict(self, X):
     39         for layer in self._layers:
---> 40             X = layer(X)
     41         return X
     42 

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/model.py in __call__(self, x)
    165             Must match expected shape
    166         """
--> 167         return self.predict(x)
    168 
    169     def pipe(self, stream, batch_size=128):

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/check.py in checked_function(wrapped, instance, args, kwargs)
    153                 if not isinstance(check, Callable):
    154                     raise ExpectedTypeError(check, ["Callable"])
--> 155                 check(arg_id, fix_args, kwargs)
    156         return wrapped(*args, **kwargs)
    157 

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/check.py in has_shape_inner(arg_id, args, kwargs)
     72             # Allow underspecified dimensions
     73             if dim is not None and arg.shape[i] != dim:
---> 74                 raise ShapeMismatchError(arg.shape, shape_values, shape)
     75 
     76     return has_shape_inner

ShapeMismatchError: 

  Shape mismatch: input (0, 668) not compatible with [None, 3924].

  Traceback:
  ├─ __call__ in /home/equalios/.conda/envs/coref2/lib/python3.8/site-packages/spacy/language.py:439
  ├─── __call__ in neural/_classes/model.py:167
  └───── predict in neural/_classes/feed_forward.py:40
         >>> X = layer(X)
​```

I'am using an embedding vector of size 300
Can any one please help me
svlandeg commented 3 years ago

Is this issue related to Issus #275 ?

aditya624 commented 3 years ago

any update for this ?

Hello everyone, i'm trying to train neuralcoref for french language. After training the model, i add it to the pipeline but when i execute this command:

doc = nlp(u"je suis firas")

I get the following error

---------------------------------------------------------------------------
ShapeMismatchError                        Traceback (most recent call last)
<ipython-input-31-0862bb3d76d3> in <module>
----> 1 doc = nlp(u"je suis firas")

~/.conda/envs/coref2/lib/python3.8/site-packages/spacy/language.py in __call__(self, text, disable, component_cfg)
    437             if not hasattr(proc, "__call__"):
    438                 raise ValueError(Errors.E003.format(component=type(proc), name=name))
--> 439             doc = proc(doc, **component_cfg.get(name, {}))
    440             if doc is None:
    441                 raise ValueError(Errors.E005.format(name=name))

neuralcoref.pyx in neuralcoref.neuralcoref.NeuralCoref.__call__()

neuralcoref.pyx in neuralcoref.neuralcoref.NeuralCoref.predict()

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/model.py in __call__(self, x)
    165             Must match expected shape
    166         """
--> 167         return self.predict(x)
    168 
    169     def pipe(self, stream, batch_size=128):

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/feed_forward.py in predict(self, X)
     38     def predict(self, X):
     39         for layer in self._layers:
---> 40             X = layer(X)
     41         return X
     42 

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/neural/_classes/model.py in __call__(self, x)
    165             Must match expected shape
    166         """
--> 167         return self.predict(x)
    168 
    169     def pipe(self, stream, batch_size=128):

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/check.py in checked_function(wrapped, instance, args, kwargs)
    153                 if not isinstance(check, Callable):
    154                     raise ExpectedTypeError(check, ["Callable"])
--> 155                 check(arg_id, fix_args, kwargs)
    156         return wrapped(*args, **kwargs)
    157 

~/.conda/envs/coref2/lib/python3.8/site-packages/thinc/check.py in has_shape_inner(arg_id, args, kwargs)
     72             # Allow underspecified dimensions
     73             if dim is not None and arg.shape[i] != dim:
---> 74                 raise ShapeMismatchError(arg.shape, shape_values, shape)
     75 
     76     return has_shape_inner

ShapeMismatchError: 

  Shape mismatch: input (0, 668) not compatible with [None, 3924].

  Traceback:
  ├─ __call__ in /home/equalios/.conda/envs/coref2/lib/python3.8/site-packages/spacy/language.py:439
  ├─── __call__ in neural/_classes/model.py:167
  └───── predict in neural/_classes/feed_forward.py:40
         >>> X = layer(X)
​```

I'am using an embedding vector of size 300
Can any one please help me
csgomezg0 commented 3 years ago

hi, has you find some solution?

aditya624 commented 2 years ago

hi, has you find some solution?

i think not yet.