• 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.

    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();

    Parameters

    • yTrue: Tensor<Rank>

      Truth Tensor.

    • yPred: Tensor<Rank>

      Prediction Tensor.

    Returns Tensor

    Cosine proximity Tensor.

    Doc

Generated using TypeDoc