Exercise 3 - who_is_it

may i ask any problem with my code? i didn’t see any wrong from here.


TypeError Traceback (most recent call last)
in
1 # BEGIN UNIT TEST
2 # Test 1 with Younes pictures
----> 3 who_is_it(“images/camera_0.jpg”, database, FRmodel)
4
5 # Test 2 with Younes pictures

in who_is_it(image_path, database, model)
30
31 # Compute L2 distance between the target “encoding” and the current db_enc from the database. (≈ 1 line)
—> 32 dist = np.linalg.norm(tf.subtract(encoding,database[db_enc]))
33
34 # If this distance is less than the min_dist, then set min_dist to dist, and identity to name. (≈ 3 lines)

TypeError: unhashable type: ‘numpy.ndarray’

Hey @Lucy_Hui,
The arguments that you have passed to the np.linalg.norm() function haven’t been properly indexed. For easily finding out how to index them, just print the arguments and their shapes before passing to the function, and you will see for yourself. If you still face an issue, feel free to let us know. I hope this helps.

Regards,
Elemento

sorry
i print shape of encoding is (1, 128)
how to print shape of database[db_enc]?
as when i print(np.shape(database[db_enc])) it shows error “local variable ‘db_enc’ referenced before assignment” what should i do then?

Try to print db_enc inside the for loop, since, as the error suggests, it is a local variable. Also, try to print the variable database[db_enc] and it’s shape. It should tell you the error. I hope this helps.

Regards,
Elemento

thanks so much Elemento