C3W3 Assignment Exercise 04

Hi,

Screenshot 2024-01-04 at 5.11.55 PM

I am stuck at this portion of Exercise 04. I am unsure of what _, n_feat mean and the expected output. Also, conceptually I understand how v1 and v2 are output based on the diagram in the videos but not sure how it can be implemented using model().

Can anyone help me on this please?

Thank you.

Hi @Nathan_Lur

Check the cells just right above “Part 3: Training” (for Exercise 02). They are almost identical (they use embedding_size there instead of n_feat here (which is more correct)).

Cheers

Thank you. Subsequently, I am getting the below error.

For v1 and v2, I am using model.output(…). Is there something wrong if i calculate accuracy = y_pred / batch_size?

Thank you.

With TensorFlow you would use model.predict to get the output of the model.

As for calculating accuracy:

  • first you need to compare y_test == y_pred
  • cast that into float (to get 1s and 0s instead of True and False)
  • sum those 1s (how many you get correct - 7434 in our case)
  • divide that by the number of samples/predictions (10240 in our case)

note, that all these steps can be achieved with one line of code.

As for your proposed solution - you cannot just divide y_pred by batch_size … y_pred is of shape 10240 and if you divide by 64, you just get 10240 numbers smaller by the factor of 64.

Cheers

Got it! Thank you!