nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java
public static double cosineSim(@NonNull INDArray d1, @NonNull INDArray d2) {
        return Nd4j.getExecutioner().execAndReturn(new CosineSimilarity(d1, d2, d1.length())).getFinalResult()
                        .doubleValue();
    }
public static double cosineSim(@NonNull INDArray d1, @NonNull INDArray d2) {
        return Nd4j.getExecutioner().execAndReturn(new CosineSimilarity(d1, d2, d1.length())).getFinalResult()
                        .doubleValue();
    }
public static double cosineSim ( @ NonNull INDArray d1 , @ NonNull INDArray d2 ) { return Nd4j . getExecutioner ( ) . execAndReturn ( new CosineSimilarity ( d1 , d2 , d1 . length ( ) ) ) . getFinalResult ( ) . doubleValue ( ) ; }
Cosine similarity

@param d1 the first vector
@param d2 the second vector
@return the cosine similarities between the 2 arrays
Cosine similarity