@ Deprecated public static void writeWordVectors ( ParagraphVectors vectors , OutputStream stream ) { try ( BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( stream , StandardCharsets . UTF_8 ) ) ) { /* This method acts similary to w2v csv serialization, except of additional tag for labels */ VocabCache < VocabWord > vocabCache = vectors . getVocab ( ) ; for ( VocabWord word : vocabCache . vocabWords ( ) ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( word . isLabel ( ) ? "L" : "E" ) . append ( " " ) ; builder . append ( word . getLabel ( ) . replaceAll ( " " , WHITESPACE_REPLACEMENT ) ) . append ( " " ) ; INDArray vector = vectors . getWordVectorMatrix ( word . getLabel ( ) ) ; for ( int j = 0 ; j < vector . length ( ) ; j ++ ) { builder . append ( vector . getDouble ( j ) ) ; if ( j < vector . length ( ) - 1 ) { builder . append ( " " ) ; } } writer . write ( builder . append ( "\n" ) . toString ( ) ) ; } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method saves paragraph vectors to the given output stream .