# Understanding the Target Score in Get_score

Hi All,

I see that the score is the mean of the classifications for the target indices, and the penalty is the mean of the norm of the difference of the current and original classifications for the “other indices”…

But why is the score defined as the mean of the classifications for the target indices? are the classifications a score of how strong a fake would get classified in the class of interest? e.g. smile classified as 5 is better than a smile classified as 3?

I couldn’t find the source code, but I assume you are speaking about loss function. We need the mean of the batch to calculate the gradients of the computational graph. This will give us a single value, from which we can start backpropagation. Please provide a code snippet so I can better understand the context.

Welcome to the community @Denis_Tran

I don’t understand the context in which you are speaking … but… We don’t assign two different integer values to a same class… This means we usually dont use two integer values suppose 5 and 3 to determine only one class ‘smile’.

So… Let me explain it to you with an example… Suppose you’re studying in a school and you get marks for 5 different subjects that you have exam on. How would we know that what is your overall performance? The answer is simple we take average ( mean ) of your marks and then we get to know that your overall performance ( evaluating you only by the marks ).
So applying this same thing on the neural network that we have … how will we know, how well our model is performing for a given target? So we take mean to know how good our model is performing…

2 Likes

Thanks,

In the Week4B assignment, step # 4. And we can take the 2nd test as an example. The original classifications are 1,2,3,4 for every images in the batch, and the current classifications stay 1,2,3,4. My interpretation of this is that the image classifications did not change as they are the same from the original.

Let’s say the other indices are 0,1,2 and target index is 3:
So if the penalty is that a classification in the “other indices” change (because they shouldnt), and we take mean(norm(current[other_indices]-original[other_indices])
case 1: 1,2,3,4 → 1,2,3,5
, should the score be higher if the class of interest gets a higher score than original (4 to 5), rather than just what the classification is (e.g. if the classification was 6 to start with)?
In other words, shouldn’t we be looking at the gradient of the classifications, rather than the value of the classifications themselves?

def get_score(current_classifications, original_classifications, target_indices, other_indices, penalty_weight):
‘’’
Function to return the score of the current classifications, penalizing changes
to other classes with an L2 norm.
Parameters:
current_classifications: the classifications associated with the current noise
original_classifications: the classifications associated with the original noise
target_indices: the index of the target class
other_indices: the indices of the other classes
penalty_weight: the amount that the penalty should be weighted in the overall score
‘’’
# Steps: 1) Calculate the change between the original and current classifications (as a tensor)
# by indexing into the other_indices you’re trying to preserve, like in x[:, features].
# 2) Calculate the norm (magnitude) of changes per example.
# 3) Multiply the mean of the example norms by the penalty weight.
# This will be your other_class_penalty.
# Make sure to negate the value since it’s a penalty!
# 4) Take the mean of the current classifications for the target feature over all the examples.
# This mean will be your target_score.