def cosine_proximity(y_true, y_pred):
 y_true = tf.nn.l2_normalize(y_true, (len(y_true.get_shape()) - 1))
 y_pred = tf.nn.l2_normalize(y_pred, (len(y_pred.get_shape()) - 1))
 return tf.reduce_sum((y_true * y_pred))

def cosine_proximity ( y_true , y_pred ) : y_true = tf . nn . l2_normalize ( y_true , ( len ( y_true . get_shape ( ) ) - 1 ) ) y_pred = tf . nn . l2_normalize ( y_pred , ( len ( y_pred . get_shape ( ) ) - 1 ) ) return tf . reduce_sum ( ( y_true * y_pred ) )
cosine similarity of two vectors .