C3_W1: Doubt in giving weights to predictions

Hello Commnity!

I hope everyone’s learning journey is going great!

I am on course 3, week 1 assignment and in there, we have given weights to model predictions. I have done the ML and DL specialization but this is new to me. My question is what is the purpose of giving weights to predictions and is it necessary to give weights?

I understand things easily with real-world examples so I am hoping that the answer to my query contains one.

Looking forward to the replies from experts and mentors.

Thank You

Hi @annoyingCode

I guess you are asking about “Example Weights” in data_generator? In which case it informs tl.WeightedCategoryCrossEntropy() which predicted outputs are more important.

Example would be in time series where past predictions are given lesser weights because they are less important (but still informative to the model).

Usually they are not necessary if all your predictions are of equal importance.

Thank You for the reply.

Well that is a good thing that you actually pre-empted the tl.WeightedCategoryCrossEntropy() . The aim of my question was the target at the end of the assignment notebook in exercise 7, compute_accuracy(preds, y, y_weights).

Yes, the y_weights here are the same example_weights from the generator. In this particular assignment we treat all examples as equally important:
# Example weights: Treat all examples equally importantly.
But you could imagine the scenarios where some examples are more important than others (for example old data weighted less than the new).
Also, in this assignment they are used the same way (equally) for accuracy adjustment.