Why does this neutralize() give different results?

In neutralize() implementation, the denominator of e_biascomponent is the square of the norm of g:

np.square(np.sqrt(np.sum(np.square(g))))

This is based on the original formula. However, this gets different results than the testing answer. The expression should be equal:

np.sum(np.square(g)))

This simplified version passed the test. Why does the two generate different results? For example:

np.square(np.sqrt(8)) = 8

Which basically np.square() cancels out np.sqrt(). But why do the two above get different results?

There’s room for small variations due to floating point operations by the CPU. That said, you can use np.isclose(norm_square(x,2), YOUR_CODE) and see that the simplified representation of np.sum(np.square(x)) is valid.

How much different are the results? Can you provide some values?

I just tried to reproduce the result by re-running the notebook, but it doesn’t output the prints after it goes to the ‘Debiasing word vectors’ section, so I can’t compare the diff of the two values now.