Hi ,
I am getting the following error which is think is related to how I am calculating the L2 distance. I am simply doing -
dist = np.linalg.norm(encoding - database[identity])
But I also see that the output of the triplet loss function is -
loss = tf.Tensor(527.2598, shape=(), dtype=float32)
The hint says to use np.linalg.norm but one of my values is a tensor so I am unsure of the way I calculate the distance.
The entire error message is:
It’s bertrand, welcome in!
TypeError 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)))
<array_function internals> in allclose(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py in allclose(a, b, rtol, atol, equal_nan)
2157
2158 “”"
→ 2159 res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
2160 return bool(res)
2161
<array_function internals> in isclose(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py in isclose(a, b, rtol, atol, equal_nan)
2255 y = array(y, dtype=dt, copy=False, subok=True)
2256
→ 2257 xfin = isfinite(x)
2258 yfin = isfinite(y)
2259 if all(xfin) and all(yfin):
TypeError: ufunc ‘isfinite’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’
Please help. thanks