Allclose() fails

TypeError                                 Traceback (most recent call last)
<ipython-input-88-166ca75f1224> in <module>
----> 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)))

<__array_function__ internals> in allclose(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/ in allclose(a, b, rtol, atol, equal_nan)
   2158     """
-> 2159     res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
   2160     return bool(res)

<__array_function__ internals> in isclose(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/ in isclose(a, b, rtol, atol, equal_nan)
   2255     y = array(y, dtype=dt, copy=False, subok=True)
-> 2257     xfin = isfinite(x)
   2258     yfin = isfinite(y)
   2259     if all(xfin) and all(yfin):

TypeError: ufunc 'isfinite' not supported for the input

Hi @avnish,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.


That is telling you that your verify function is incorrect. Notice that you fail the very first such case. The first step would be to print the actual values you get from calling verify with those inputs. What answers did you get? Then you need to compare your code to the instructions to figure out where your code is different. There aren’t very many moving parts in this function. The only thing that stands out as a potential problem is that here they want you to use just the L2 norm of the difference between the two encodings as the distance, whereas in the triplet_loss case they had us use the square of the L2 norm.

Just for grins, I tried making the mistake of using the square of the L2 norm and here’s the incorrect answer that gives me:

Dist for bertrand = tf.Tensor(0.29555342, shape=(), dtype=float32)
It's bertrand, welcome in!

Does that look familiar? :nerd_face:

Thanks guys … I am good !!!