I got the error in predict function. The error shows when I’m calling function “get_sentence_vectorizer(sentence)” but that function I passed. I searched for an error but I cannot understand.
Can you share image of complete error, probably in two screenshots!!!
get_sentence_vectorizer is not in the predict function scope (and it is not the function you would want to use - it returns a function and a vocabulary. What you want is to “vectorize” the sentence with a vectorizer that is in the scope of the predict function).
You should be using sentence_vectorizer.
Cheers
is this for the same unittest?
this is correct.
issue could be related to
Get a list of all keys, remember that the tag_map was built in a way that each label id matches its index in a list
HERE YOU RECALLED list of tag_map.keys as labels
THEN prediction with empty string which you then
Iterating over every predicted token in outputs list
Create for loop for tag idx in outputs
check if predicted labels are equal to labels of tag_ids
which gets append to pred
Regards
DP
Yes, it is the same function and unittest.
Please DM your codes from the predict grade cell. Click on my name and then message.
Sorry for the late reply, somehow I missed your DM.
Okay codes in the screenshot you shared here in previous comment are correct but because your model output from sentenced you vectorised is incorrect, you are getting this error.
Remember in the code line
Get the model output, doesn’t mean you get model of the sentence you vectorised.
Hint: The parameter mentions
model (tf.keras.Model): Trained NER model.
then Predict NER labels for a given sentence using a trained model.
Probably the below screenshot is more of direct hint for the correction.
Regards
DP
Yes. pred_label codes are correct
that clue was only related to the model output and not the label value.
Your pred_label codes are correct as mentioned in previous comment
Thanks. Problem solved by for tag_idx in outputs[0]. I change outputs to outputs[0].









