Last part of Programming assignment W2

I have:

{moderator edit - solution code removed}

[[10.05051235 2.0828533 -0.48089952 -4.97268808]
[ 2.0828533 10.89214084 5.0277819 3.98804526]
[-0.48089952 5.0277819 9.98912851 2.14735945]
[-4.97268808 3.98804526 2.14735945 11.02674517]]
(4, 4)
<class ‘numpy.ndarray’>
target_index: 1
relevant_indices: [0 1 2 3]
highest_covariances: [0 3 2 1]

AssertionError Traceback (most recent call last)
Input In [13], in <cell line: 15>()
12 foo = samples.reshape(60, 128, samples.shape[-1])
14 relevant_indices, highest_covariances = get_top_covariances(foo, 1, top_n=3)
—> 15 assert (tuple(relevant_indices) == (2, 3, 0)), “Make sure you’re getting the greatest, not the least covariances”
16 assert np.all(np.abs(highest_covariances - [5, 4, 2]) < 0.5 )
18 relevant_indices, highest_covariances = get_top_covariances(foo, 0, top_n=3)

AssertionError: Make sure you’re getting the greatest, not the least covariances

The indices are wrong. In target indexes there are: [ 2.0828533 10.89214084 5.0277819 3.98804526]. So, the order for the highest indexes are: 1,2,3,0 and the highest values are: 10.89, 5, 3.99, 2.08 . What is causing this error?

You missed one step: you also need to remove the target_index from the list. The “self correlation” is not of interest for our purposes, right?

Well, you may also have missed some things after that step as well, but that should get you on the right track …

Del

Hi Stefan!

Please don’t post your code in the forum, it violates the community guidelines. Kindly delete it. And commenting the test cases is not a way to find your way to the solution in my opinion; You can always print your intermediate results and debug. Check out the optional hints given in the notebook to help you solve the issues you face during the implementation (You are missing some steps).

Regards,
Nithin