Update mnist_siamese_graph example
Take max of squared distance and K.epsilon() because some data points will throw `nan` for euclidean distance.
@@ -24,7 +24,7 @@ from keras import backend as K
def euclidean_distance(vects):
x, y = vects
- return K.sqrt(K.sum(K.square(x - y), axis=1, keepdims=True))
+ return K.sqrt(K.maximum(K.sum(K.square(x - y), axis=1, keepdims=True), K.epsilon()))
def eucl_dist_output_shape(shapes):
