List of usage examples for org.deeplearning4j.models.embeddings.loader WordVectorSerializer writeParagraphVectors
public static void writeParagraphVectors(ParagraphVectors vectors, OutputStream stream) throws IOException
From source file:dollar.learner.smart.ParagraphVectorsClassifierExample.java
License:Apache License
public void stop() { log.info("Saving to " + serializeFile().getAbsolutePath()); WordVectorSerializer.writeParagraphVectors(paragraphVectors, serializeFile()); }
From source file:org.knime.ext.textprocessing.dl4j.util.WordVectorPortObjectUtils.java
License:Open Source License
/** * Writes {@link WordVectors} to specified {@link ZipInputStream}. Calling this method will close the stream (closed * by WordVectorSerializer)./*from ww w. j a v a 2 s .c om*/ * * @param wordVectors {@link WordVectors} to write * @param out stream to write to * @throws IOException */ public static void writeWordVectors(final WordVectors wordVectors, final ZipOutputStream out) throws IOException { final ZipEntry entry = new ZipEntry("word_vectors"); out.putNextEntry(entry); //first check if ParagraphVectors because it extends Word2Vec if (wordVectors instanceof ParagraphVectors) { ParagraphVectors d2v = (ParagraphVectors) wordVectors; WordVectorSerializer.writeParagraphVectors(d2v, out); } else if (wordVectors instanceof Word2Vec) { Word2Vec w2v = (Word2Vec) wordVectors; WordVectorSerializer.writeWord2VecModel(w2v, out); } else { throw new IllegalStateException("No serialization method defined for WordVectors of type: " + wordVectors.getClass().getSimpleName()); } }