Updated NER: masked_accuracy function

Hej,
I’m getting error/got stuck on the ex.5 - masked_accuracy.

"InvalidArgumentError: {{function_node _wrapped__Mul_device/job:localhost/replica:0/task:0/device:GPU:0}} required broadcastable shapes [Op:Mul] name: "

The. error is thrown in this line but it might be caused by previous mistakes:
matches_true_pred *= None
I don’t want to violate CoC but the answer for this line was in the lecture and I did the same.

Going from a top what should be updated by me in the ex.
mask => I’m checking with tf.equal if y_pred is == -1
y_pred_class => tf.math.argmax, same as in the lecture
matches_true_pred => comparing t_true and y_pred_class

Is there any obvious mistake in the above logic? I can’t see it.
Thank you in advance for all help

Hi @mats, are looking at the latest version of the course (Tensorflow instead of Trax)? I ask since in the new version this assignment is in week 2.

You’re right. It’s week 2 in the refreshed training. The assignment is on TF not trax.
The category was wrongly selected and I don’t know how to change it.

@lucas.coutinho can help with this

Hi @mats!

Are you passing the axis argument in tf.math.argmax? If you do not pass the axis argument, it is default to 0, which means you are performing the argmax across the columns and this is not what you want.

Furthermore, I would like just to point that the mask should indicate the values that are different from -1 and not equal to -1, otherwise you will be removing the non masked values after masking.

Please, tell me if this helps.

Cheers,
Lucas

1 Like

This is in the TensorFlow version of the assignment…I’m getting the same error message:

In tf.math.argmax I’ve got an axis assigned; however, if I have the mask that indicate the values not equal to -1 the code fails the unittest and generates the above error. That is, if the mask indicates the values equal to -1 then it passes the unittest but also generates the above error message.

I’ve tried different values for the axis in argmax and only one value doesn’t generate an error.

Any suggestions on where I might have gone wrong?

Could some one please explain more about the mask values?

@lucas.coutinho Thank you for helping us in learning NLP. I am struggling to get the masked_accuracy function correct . Could you please help me in understand the function more? I don’t understand mask values and I have some doubts regarding y_true and y_pred. Could you please help me in that? If possible can we have quick chat/call? Please help.

@lucas.coutinho Thank you for helping us in learning NLP. I am struggling to get the masked_accuracy function correct . Could you please help me in understand the function more? I don’t understand mask values and I have some doubts regarding y_true and y_pred. Could you please help me in that? If possible can we have quick chat/call? Please help.

Was your issue resolved?? or you still need help?

the error tells more correct related to the mask. let me know if you still need help

I need help in this case the masked accuracy function is raising some problem regarding the tensor being broadcastable and not. The shape depicts it is (1,) but changes into some other by running it. May you help in this regard?

Solved the issue for me! Thank you so much!