For the assignment I have followed the instruction given however I still cannot get the correct output for the Entanglement and Regularization part.

Written in Pseudocode this is what my current implementation has:

other_distances = norm of tensor of original_classifications[other_indices] - current_classifications[other_indices]`
other_class_penalty = negate mean of other_distances * penalty_weight
target_score = mean of current_classifications[target_indices]

Hi Pablo,
A couple things to look at, based on your pseudocode:

Have you done step 1, mentioned in the comments:

# 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].

Click on the â€śOptional Hints for get_scoreâ€ť and make sure youâ€™re following all the suggestions. In particular, make sure you are passing a dim argument to torch.norm

Once you have code you think is right, you can also use the unit tests to help you narrow down the problem. You may want to add some print statements temporarily to help you. For example, if a test is failing, you can print the value youâ€™re calculating vs the expected value to help give you some idea about why your value isnâ€™t the same as expected.

Emphasis on taking the mean of ( difference between current and original classifications), ie be careful the order of operations and what is subtracted from what.

Nevermind found the error.
Basically I forgot to put dim = 1 in torch.norm, since I was just calling torch.norm(other_distances, 1) therefore I was calling the p argument not the dim argument of torch.norm
Many thanks for all the help