# C3_W2_RecSysNN_Assignmen square-distance issue

I understand that calculating the square distance between 2 arrays, you can do that in one line. How can I show my line (that doesn’t work)?

Hi @Alain

Have you had a look at the hint? If you click on that, you will see text expansion giving suggestions on the functions to use for this calculation.

Hi @Kic

I have read it as well as related posts but I’m still stuck. My line doesn’t work.

Hi @Alain

So let’s break down the steps to get it working:

• subtract numpy array ‘a’ from ‘b’ elementwise. You can do that by using np.substract() function or simply a - b
• use np.square() to get the square of each resulting elements
• use np.sum() to add all the squared elements to give you a scalar value for the distance.
2 Likes

Thanks @Kic for your helpful guidance. I was going on some crazy tangent by looking up other crazy methods in tensorflow.

Thanks again and take care,
Alain

thank you for this guidance I was stuck as well, its very simple, 3 points explained, 3 lines of code

Hello did you made any definition of a or b?, I get a message that ““module ‘numpy’ has no attribute ‘substract’””

I’m not sure if only a,b should be inside the substract or how it should go, thanks in advance.

Here is an explaination of squared distance. If you want to do element-wise subtraction, you may use this numpy function.

Cheers,
Raymond

hi, I’m using that function, but for some reason, it is not working properly. It shows me the message of “module ‘numpy’ has no attribute ‘substract’”, hence my question if I should declare in any space “a” and “b”, on the numpy guidance I don’t see anything different.

{code removed by mentor}