Loss or metric function: Cosine proximity.
Mathematically, cosine proximity is defined as: -sum(l2Normalize(yTrue) * l2Normalize(yPred)), wherein l2Normalize() normalizes the L2 norm of the input to 1 and * represents element-wise multiplication.
-sum(l2Normalize(yTrue) * l2Normalize(yPred))
l2Normalize()
*
const yTrue = tf.tensor2d([[1, 0], [1, 0]]);const yPred = tf.tensor2d([[1 / Math.sqrt(2), 1 / Math.sqrt(2)], [0, 1]]);const proximity = tf.metrics.cosineProximity(yTrue, yPred);proximity.print(); Copy
const yTrue = tf.tensor2d([[1, 0], [1, 0]]);const yPred = tf.tensor2d([[1 / Math.sqrt(2), 1 / Math.sqrt(2)], [0, 1]]);const proximity = tf.metrics.cosineProximity(yTrue, yPred);proximity.print();
Truth Tensor.
Prediction Tensor.
Cosine proximity Tensor.
Generated using TypeDoc
Loss or metric function: Cosine proximity.
Mathematically, cosine proximity is defined as:
-sum(l2Normalize(yTrue) * l2Normalize(yPred))
, whereinl2Normalize()
normalizes the L2 norm of the input to 1 and*
represents element-wise multiplication.