You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I recently took this course on DataCamp and did manage to run the code in the exercise. For future references, I copied the exercise and the answer to my own notebook using Jupyter. However, when I tried to run the code, I encountered an error.
This is the original code:
import random
# Start the training
nlp.begin_training()
# Loop for 10 iterations
for itn in range(10):
# Shuffle the training data
random.shuffle(TRAINING_DATA)
losses = {}
# Batch the examples and iterate over them
for batch in spacy.util.minibatch(TRAINING_DATA, size=2):
texts = [text for text, entities in batch]
annotations = [entities for text, entities in batch]
# Update the model
nlp.update(texts, annotations, losses=losses)
print(losses)
And this is the error I got:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-aa733910c3ca> in <module>
18
19 # Update the model
---> 20 nlp.update(texts, annotations, losses=losses)
21 #example = Example.from_dict(nlp.make_doc(texts), annotations)
22 #nlp.update([example])
~\anaconda3\lib\site-packages\spacy\language.py in update(self, examples, _, drop, sgd, losses, component_cfg, exclude)
1086 """
1087 if _ is not None:
-> 1088 raise ValueError(Errors.E989)
1089 if losses is None:
1090 losses = {}
ValueError: [E989] `nlp.update()` was called with two positional arguments. This may be due to a backwards-incompatible change to the format of the training data in spaCy 3.0 onwards. The 'update' function should now be called with a batch of Example objects, instead of `(text, annotation)` tuples.
I'm sorry if it looks a bit confusing, but this error has been bugging me for weeks now, and I tried to find the solution through stackoverflow and applied them here, but nothing seems to work out. Really appreciate it if the author herself or anyone here can explain what happened.
Thank you.
The text was updated successfully, but these errors were encountered:
Hi, this code looks like it was written for spaCy v2.x.
The version of the course at https://course.spacy.io should be compatible with spacy==2.3.5. It's possible this is a slightly older version and you might need spacy==2.2.4 instead.
Hi! I recently took this course on DataCamp and did manage to run the code in the exercise. For future references, I copied the exercise and the answer to my own notebook using Jupyter. However, when I tried to run the code, I encountered an error.
This is the original code:
And this is the error I got:
I'm sorry if it looks a bit confusing, but this error has been bugging me for weeks now, and I tried to find the solution through stackoverflow and applied them here, but nothing seems to work out. Really appreciate it if the author herself or anyone here can explain what happened.
Thank you.
The text was updated successfully, but these errors were encountered: