C4W1 Exercise 5 Translate : Vectorize the text using the correct vectorizer

In function translate I dont know how to declare context " Vectorize the text using the correct vectorizer". Firstly, I used original_sentence that in test function. It’s show not define. Then, I use
english_vectorizer and the error show I tried to define parameters by using global variable.

1 Like

Did you try searching similar threads?

Also you will find the solution in the assignment only, go back to previous sections where you will find some of the hints.

Is the hints that you mean ? I seached similar thread but still confused but I will explore more a bit.

context = english_vectorizer(texts).to_tensor()

1 Like

Actually @skinx.learning

until you do not share any detail of where you are getting stuck, others can only assume, so it is better you share a screenshot of the error you were talking about, so we get an idea to direct you.

Regards
DP

This is my error when I tried to use english_vectorizer to vectorize the text

and This is original_sentence


Do you have any clue ?

1 Like

Hi @skinx.learning

if the issue is with the conversion into vector

refer the section just before
Exercise 5 translate (instruction section)

with cell header
PROCESS SENTENCE TO TRANSLATE AND ENCODE

You will find all the hints there

Let me know if you still couldn’t get it.

Vectorize the text using the correct vectorizer
using original_Sentence is giving you the error recall of global variable as you were required to use english_vectorizer

Regards
DP

I edit tf.convert_to_tensor with original sentence but I still dont get it what vectorizer will be use in …(text).to_tensor()

1 Like

did you read this?

Yes, please. I used “english_vectorizer(text_tensor).to_tensor()” but it’s show the following error.

1 Like

then that means one need to go back and look into the decoder section as your error clearly mentioned wrong decoder.

Check if for the
The dense layer with logsoftmax activation
you have recalled the unit correctly as instruction mentions
This one should have the same number of units as the size of the vocabulary since you expect it to compute the logits for every possible word in the vocabulary

I re-read and I think I defined it correctly(not sure)

tf.keras.layers.Dense(
units=vocab_size,
activation=tf.nn.log_softmax
)
I notice that show test passed but the value not matched to the expected
Screenshot 2567-05-07 at 00.31.52

1 Like

I hope you know what is 14 in the 64,14

so basically for context shape your output is matching, but for the next two your unit is incorrect

to understand this you probably need to go once through
GRADED CLASS: CrossAttention where the unit is same as you need for this output.

Also check in the GRADED CELL Decoder

Check how you recall The attention layer as it requires cross-attention.

once you have recalled all the layer you pass the layer to def call
where you need to recall the layers correctly as per you recalled above,
for example the code recall instruction mentions

Pass the embedded input into the pre attention LSTM
but you are suppose to use self.pre_attention_rnn

then Perform cross attention between the context and the output of the LSTM (in that order) which is basically self.attention

But I feel your issue could be with any of the following, kindly do debugging step-wise, go one code at a time.

Regards
DP

1 Like

Hi @skinx.learning

Please make use of the search function of the forum. This mistake is very common and there are a lot of posts how to fix it. For example, searching (64, 14, 256) and other keywords would give you many results. Some of them:

In short, you’re probably embedding the context not the target. But I would advise to make use of the forum’s search functionality prior to posting a new thread.

Cheers

3 Likes

Appreciated that :face_holding_back_tears: Thanks for your information.

1 Like

No problem :+1: Just wanted to help you find the solutions faster and more efficient (and it is also good for learning - trying to solve the problem on many angles, instead of getting an answer right away). The general advice would be to:

  • search the forum for the problematic function name
  • search the forum for the problematic function output (either the error message, or test case output)
  • just browse some topics on the specific course and specific week.

I believe majority of mistakes could be found that way. For the other cases, I would advise to post what the error is and what you tried. That way you narrow down suggestions for your particular case.

Cheers

1 Like