DL4J: How to calculate Cosine Similarity between INDArray obtained from getWordVectorsMean

267
February 06, 2018, at 5:40 PM

I have calculated VectorMean of two sentences like this:

String demoString1 = "Enter first label";
String demoString2 = "Enter first name";
        Collection<String> label1 = Splitter.on(' ').splitToList(demoString1);
        Collection<String> label2 = Splitter.on(' ').splitToList(demoString2);
        System.out.println("label1:==>"+label1);
        System.out.println("getWordVectorMatrix->INDArray------------------"+vectors.getWordVectorsMean(label1));
        System.out.println("label2:==>"+label2);
        System.out.println("getWordVectorMatrix->INDArray------------------"+vectors.getWordVectorsMean(label2));

Output:

label1:==>[Enter, first, label]
getWordVectorMatrix->INDArray------------------[0.02,  -0.14,  0.07,  -0.10,.............100 dimension vector]
label2:==>[Enter, first, name]
getWordVectorMatrix->INDArray------------------[-0.00,  -0.15,  0.07,  -0.13,............100 dimension vector]

Now how I can calculate similarity(Cosine Similarity) between both sentences using their mean ? I searched, but I couldn't find any API available in DL4J.

Rent Charter Buses Company
READ ALSO
Jedis Subscribe thread get Connection time out exception every fixed interval

Jedis Subscribe thread get Connection time out exception every fixed interval

In my application i have 4 redis channel , the application subscribes to this channel in 4 different thread , but in long run for every 4 hours i get the exception in all 4 threads which had subscribed to those channels

215
Can we fully change android source code in App Update?

Can we fully change android source code in App Update?

We want to update our published app in google playBut I want to confirm can we fully change android source code expect package name

188
date in java using format only

date in java using format only

I'm trying to validate the date with the given formatI wrote the below code but it is only checking whether the given date is matching with the format or not

175
Unable to upload zip file from Android to server sendto failed: epipe (broken pipe)

Unable to upload zip file from Android to server sendto failed: epipe (broken pipe)

I am creating a android application that will be used to upload the zip file from local file system to the serverBelow is my file upload code

314