Keep getting a ValueError: Out shape is mismatched
#11208
-
I'm trying to train a new Steps i'm taking1. I first get my labeled data into the doc format and save the train and dev files in a new folder.How I'm adding the text and annotations # load a new spacy model
nlp = spacy.blank("en")
nlp.add_pipe("ner")
# incase we have bad labels i can see which ones and go back and fix it later
bad_labels = []
# create a DocBin object
db_train = DocBin()
db_test = DocBin()
# adding in train_set to doc
train_skip = 0
validation_skip = 0
for text_train, annot in X_train:
doc = nlp.make_doc(text_train) # create doc object from text
ents = []
for start, end, label in annot["entities"]: # add character indexes
span = doc.char_span(start, end, label=label) #, alignment_mode="contract"
if span is None:
train_skip +=1
pass
else:
ents.append(span)
try:
# label the text with the ents
doc.ents = ents
db_train.add(doc)
except ValueError: # when there are overlapping labels
print(f"Sentence skipped")
train_skip += 1
bad_labels.append( (text_train, annot) )
pass
# adding in validation to doc
for text_val, annot in X_val:
doc = nlp.make_doc(text_val) # create doc object from text
ents = []
for start, end, label in annot["entities"]: # add character indexes
span = doc.char_span(start, end, label=label) #, alignment_mode="contract"
if span is None:
validation_skip +=1
pass
else:
ents.append(span)
try:
# label the text with the ents
doc.ents = ents
db_test.add(doc)
except ValueError: # when there are overlapping labels
print(f"Sentence skipped")
validation_skip += 1
bad_labels.append( (text_val, annot) )
pass
db_train.to_disk(file_path + "/train.spacy") # save the docbin object
db_test.to_disk(file_path + "/dev.spacy") # save the docbin object 2. Then I make a new config which seems to give a good outputos.chdir(f"/content/drive/Shareddrives/Data/NER/sent_exploration/spacy_models/{folder_name}/")
!python -m spacy init config config.cfg --lang en --pipeline "transformer, ner" --gpu --optimize accuracy --force Output from initializing a config
3. Finally I call the training CLI
But I keep getting this error
debug dataI've tried running the `debug output`* **I will be annotating and adding more in later, but I wanted to make sure things will work so far.**
What i've tried so far
My
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
⭐️ Sort of a fix ⭐️Downgrading to spacy 3.3 seemed to do the trick and get everything working again.
packages that got downgraded
I'm assuming there either:
Either way, I just hope this post might help anyone else who might have been stuck in the same position I was. :) |
Beta Was this translation helpful? Give feedback.
-
Thanks again for the report! 3.4.1 is now available which should hopefully fix things. Let us know if you do still run into problems though! |
Beta Was this translation helpful? Give feedback.
-
I am facing the same issue. I was able to train custom NER models till last night. From today, I am unable to. I am doing this Google Colab Pro+. Please help. |
Beta Was this translation helpful? Give feedback.
Thanks again for the report! 3.4.1 is now available which should hopefully fix things. Let us know if you do still run into problems though!