How it works...
In step 1, we used loadStaticModel() to load the model from the given path; however, you can also use readWord2VecModel(). Unlike readWord2VecModel(), loadStaticModel() utilizes host memory.
In step 2, FileLabeledSentenceProvider is used as a data source to load the sentences/documents from the files. We created CnnSentenceDataSetIterator using the same. CnnSentenceDataSetIterator handles the conversion of sentences to training data for CNNs, where each word is encoded using the word vector from the specified word vector model. Sentences and labels are provided by a LabeledSentenceProvider interface. Different implementations of LabeledSentenceProvider provide different ways of loading the sentence/documents with labels.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access