i’m getting the rerror in verify() function of week 4 assignment 1.
Any help is appreciated
My code is:
Step 1: Compute the encoding for the image. Use img_to_encoding() see example above. (≈ 1 line)
encoding = img_to_encoding(image_path,model)
# Step 2: Compute distance with identity's image (≈ 1 line)
dist = np.linalg.norm(database[identity],encoding)
# Step 3: Open the door if dist < 0.7, else don't open (≈ 3 lines)
if dist< 0.7:
print("It's " + str(identity) + ", welcome in!")
door_open = True
else:
print("It's not " + str(identity) + ", please go away")
door_open = False
the error its giving
ValueError Traceback (most recent call last)
in
1 # BEGIN UNIT TEST
----> 2 assert(np.allclose(verify(“images/camera_1.jpg”, “bertrand”, database, FRmodel), (0.54364836, True)))
3 assert(np.allclose(verify(“images/camera_3.jpg”, “bertrand”, database, FRmodel), (0.38616243, True)))
4 assert(np.allclose(verify(“images/camera_1.jpg”, “younes”, database, FRmodel), (1.3963861, False)))
5 assert(np.allclose(verify(“images/camera_3.jpg”, “younes”, database, FRmodel), (1.3872949, False)))
in verify(image_path, identity, database, model)
20 encoding = img_to_encoding(image_path,model)
21 # Step 2: Compute distance with identity’s image (≈ 1 line)
—> 22 dist = np.linalg.norm(database[identity],encoding)
23 # Step 3: Open the door if dist < 0.7, else don’t open (≈ 3 lines)
24 if dist< 0.7:
<array_function internals> in norm(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/numpy/linalg/linalg.py in norm(x, ord, axis, keepdims)
2468 if ((ord is None) or
2469 (ord in (‘f’, ‘fro’) and ndim == 2) or
→ 2470 (ord == 2 and ndim == 1)):
2471
2472 x = x.ravel(order=‘K’)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()