@Test @Ignore public void testParagraphVectorsReducedLabels1() throws Exception { val tempDir = testDir.newFolder(); ClassPathResource resource = new ClassPathResource("/labeled"); resource.copyDirectory(tempDir); LabelAwareIterator iter = new FileLabelAwareIterator.Builder().addSourceFolder(tempDir).build(); TokenizerFactory t = new DefaultTokenizerFactory(); ParagraphVectors vec = new ParagraphVectors.Builder().minWordFrequency(1).epochs(3).layerSize(100) .stopWords(new ArrayList<String>()).windowSize(5).iterate(iter).tokenizerFactory(t).build(); vec.fit(); INDArray w1 = vec.lookupTable().vector("I"); INDArray w2 = vec.lookupTable().vector("am"); INDArray w3 = vec.lookupTable().vector("sad."); INDArray words = Nd4j.create(3, vec.lookupTable().layerSize()); words.putRow(0, w1); words.putRow(1, w2); words.putRow(2, w3); INDArray mean = words.isMatrix() ? words.mean(0) : words; log.info("Mean" + Arrays.toString(mean.dup().data().asDouble())); log.info("Array" + Arrays.toString(vec.lookupTable().vector("negative").dup().data().asDouble())); double simN = Transforms.cosineSim(mean, vec.lookupTable().vector("negative")); log.info("Similarity negative: " + simN); double simP = Transforms.cosineSim(mean, vec.lookupTable().vector("neutral")); log.info("Similarity neutral: " + simP); double simV = Transforms.cosineSim(mean, vec.lookupTable().vector("positive")); log.info("Similarity positive: " + simV); }
@Override public void fit() { super.fit(); extractLabels(); }
ParagraphVectors extends Word2Vec { @Override public void fit() { super.fit(); extractLabels(); } }
ParagraphVectors extends Word2Vec { @Override public void fit() { super.fit(); extractLabels(); } protected  ParagraphVectors(); }
ParagraphVectors extends Word2Vec { @Override public void fit() { super.fit(); extractLabels(); } protected  ParagraphVectors(); @Deprecated String predict(String rawText); void setSequenceIterator(@NonNull SequenceIterator<VocabWord> iterator); String predict(LabelledDocument document); void extractLabels(); INDArray inferVector(String text, double learningRate, double minLearningRate, int iterations); INDArray inferVector(LabelledDocument document, double learningRate, double minLearningRate,
                    int iterations); INDArray inferVector(@NonNull List<VocabWord> document, double learningRate, double minLearningRate,
                    int iterations); INDArray inferVector(String text); INDArray inferVector(LabelledDocument document); INDArray inferVector(@NonNull List<VocabWord> document); Future<Pair<String, INDArray>> inferVectorBatched(@NonNull LabelledDocument document); Future<INDArray> inferVectorBatched(@NonNull String document); List<INDArray> inferVectorBatched(@NonNull List<String> documents); String predict(List<VocabWord> document); Collection<String> predictSeveral(@NonNull LabelledDocument document, int limit); Collection<String> predictSeveral(String rawText, int limit); Collection<String> predictSeveral(List<VocabWord> document, int limit); Collection<String> nearestLabels(LabelledDocument document, int topN); Collection<String> nearestLabels(@NonNull String rawText, int topN); Collection<String> nearestLabels(@NonNull Collection<VocabWord> document, int topN); Collection<String> nearestLabels(INDArray labelVector, int topN); @Deprecated double similarityToLabel(String rawText, String label); @Override void fit(); double similarityToLabel(LabelledDocument document, String label); double similarityToLabel(List<VocabWord> document, String label); String toJson(); static ParagraphVectors fromJson(String jsonString); }
ParagraphVectors extends Word2Vec { @Override public void fit() { super.fit(); extractLabels(); } protected  ParagraphVectors(); @Deprecated String predict(String rawText); void setSequenceIterator(@NonNull SequenceIterator<VocabWord> iterator); String predict(LabelledDocument document); void extractLabels(); INDArray inferVector(String text, double learningRate, double minLearningRate, int iterations); INDArray inferVector(LabelledDocument document, double learningRate, double minLearningRate,
                    int iterations); INDArray inferVector(@NonNull List<VocabWord> document, double learningRate, double minLearningRate,
                    int iterations); INDArray inferVector(String text); INDArray inferVector(LabelledDocument document); INDArray inferVector(@NonNull List<VocabWord> document); Future<Pair<String, INDArray>> inferVectorBatched(@NonNull LabelledDocument document); Future<INDArray> inferVectorBatched(@NonNull String document); List<INDArray> inferVectorBatched(@NonNull List<String> documents); String predict(List<VocabWord> document); Collection<String> predictSeveral(@NonNull LabelledDocument document, int limit); Collection<String> predictSeveral(String rawText, int limit); Collection<String> predictSeveral(List<VocabWord> document, int limit); Collection<String> nearestLabels(LabelledDocument document, int topN); Collection<String> nearestLabels(@NonNull String rawText, int topN); Collection<String> nearestLabels(@NonNull Collection<VocabWord> document, int topN); Collection<String> nearestLabels(INDArray labelVector, int topN); @Deprecated double similarityToLabel(String rawText, String label); @Override void fit(); double similarityToLabel(LabelledDocument document, String label); double similarityToLabel(List<VocabWord> document, String label); String toJson(); static ParagraphVectors fromJson(String jsonString);  }