Getting issue in NLP C3W2 Assignment exercise 6

Hi NLP learning community! I am attempting NLP course 3 week 2 assignment of NER. I passed first 5 tasks but at the last task I’m stuck not able to complete. I spend whole day and implement correctly but it does not working. I don’t know what I do next and feeling disappoint. I can’t share code here because it’s not allowed. Anyone here can just give me hints.

I am getting this error in predict function implementation.

Your function could not be tested due an error. Please make sure you are passing the correct tensor to the model call. You need to expand its dimension before calling the model.

  • Test failed.*
1 Like

Hi @Muhammad_Hamza9

The problem seems to lie in your implementation of:
# Expand its dimension to make it appropriate to pass to the model

and the instructions for this are:

To get a single prediction from a tensorflow model, you will need to make some changes in the input array, since tensorflow expects a batch of sentences. You can use the function tf.expand_dims to do this.

In other words, first you vectorize the input sentence, then you do this step with adding batch dimension. Does that make sense?

1 Like

You should not wrap the sentence into a list like: [sentence]. And you don’t need padding here like in the first attempt.

So your second attempt is better, but it should be without wrapping the sentence into a list.

1 Like

This code is perfectly fine, the mistake is elsewhere.

1 Like

Then What do I do?
Can we share contact here to get help personally?

1 Like