Example usage for org.deeplearning4j.text.documentiterator LabelsSource getLabels

List of usage examples for org.deeplearning4j.text.documentiterator LabelsSource getLabels

Introduction

In this page you can find the example usage for org.deeplearning4j.text.documentiterator LabelsSource getLabels.

Prototype

public List<String> getLabels() 

Source Link

Document

This method returns the list of labels used by this generator instance.

Usage

From source file:com.github.tteofili.p2h.Par2HierUtils.java

License:Apache License

/**
 * transforms paragraph vectors into hierarchical vectors
 * @param iterator iterator over docs//from  w  w  w .  j a v a2 s  . c  o  m
 * @param lookupTable the paragraph vector table
 * @param labels the labels
 * @param k the no. of centroids
 * @return a map doc->hierarchical vector
 */
static Map<String, INDArray> getPar2Hier(LabelAwareIterator iterator, WeightLookupTable<VocabWord> lookupTable,
        List<String> labels, int k, Method method) {
    Collections.sort(labels);
    LabelsSource labelsSource = iterator.getLabelsSource();
    PatriciaTrie<String> trie = new PatriciaTrie<>();
    for (String label : labels) {
        trie.put(label, label);
    }

    Map<String, INDArray> hvs = new TreeMap<>();
    // for each doc
    for (String node : labelsSource.getLabels()) {
        Par2HierUtils.getPar2HierVector(lookupTable, trie, node, k, hvs, method);
    }
    return hvs;
}