The first implementation looks correct to me. The second one is clearly wrong: you are passing two separate vector arguments to np.linalg.norm, but it takes only one. The other arguments are things like ord, not other vectors. You did read the documentation, right? The point is we are computing the length of the difference between the computed encoding and the database version, so we need to subtract the two vectors first, which is what your first solution correctly does.
So what I bet happened is that after you typed in the correct code, you did not hit “Shift - Enter” to “compile” (well it’s really an interpreter, but whatever ) the new version. So you were not running the correct code. Type in that code again and then make sure everything is consistent by doing “Kernel → Restart and Clear Output” and then “Cell → Run All” and see if it works now. It’s important to remember that the notebooks are not really a WYSIWYG interface. What you are running is not necessarily what you are seeing unless you are paying careful attention to execute the function cells after typing in them. Just calling the function again runs the old code. You can easily demonstrate this effect to yourself. Take a function that works and now add a print statement in the body of the function, but do not hit “Shift - Enter”. Now call the function again from the test cell and no print comes out, right? Now hit “Shift - Enter” on the actual function cell and then run the test cell again. Bingo! Give it a try!
That error was from the second incorrect version of your code, right? I already explained why that is wrong. Try the first version again.
Also what do you mean by “downloaded just this month”? If you are running the notebooks in some environment other than the course website, then all bets are off. It is a huge hassle to get all the stuff downloaded and all the right versions of software configured.
Where did I say anything about versions of the notebook? I’m talking about versions of your code. I suggest you read my first reply again more carefully.
But the point is that you are using the wrong version of your code. I explained all of this in my original reply on this thread. np.linalg.norm takes only one vector as the argument. Did you read the documentation?
But think about what it is the instructions tell you to do:
Compute the vector difference between the computed encoding and the database version for the relevant person.
Compute the 2-norm of that difference vector.
Where in your code do you compute the difference? You did in the original version you showed in your first post on this thread.
Did you notice that your code for “if dist > 0.7…” is incorrect?
A small distance value indicates the that picture matches the database.
That’s why the comment says “Step 3: Open the door if dist < 0.7…”
Your logic is backwards.