@ Override public INDArray inferSequence ( Sequence < T > sequence , long nr , double learningRate , double minLearningRate , int iterations ) { AtomicLong nextRandom = new AtomicLong ( nr ) ; // we probably don't want subsampling here // Sequence<T> seq = cbow.applySubsampling(sequence, nextRandom); // if (sequence.getSequenceLabel() == null) throw new IllegalStateException("Label is NULL"); if ( sequence . isEmpty ( ) ) return null ; Random random = Nd4j . getRandomFactory ( ) . getNewRandomInstance ( configuration . getSeed ( ) * sequence . hashCode ( ) , lookupTable . layerSize ( ) + 1 ) ; INDArray ret = Nd4j . rand ( new int [ ] { 1 , lookupTable . layerSize ( ) } , random ) . subi ( 0.5 ) . divi ( lookupTable . layerSize ( ) ) ; log . info ( "Inf before: {}" , ret ) ; for ( int iter = 0 ; iter < iterations ; iter ++ ) { for ( int i = 0 ; i < sequence . size ( ) ; i ++ ) { nextRandom . set ( Math . abs ( nextRandom . get ( ) * 25214903917L + 11 ) ) ; dm ( i , sequence , ( int ) nextRandom . get ( ) % window , nextRandom , learningRate , null , true , ret , null ) ; } learningRate = ( ( learningRate - minLearningRate ) / ( iterations - iter ) ) + minLearningRate ; } finish ( ) ; return ret ; }
This method does training on previously unseen paragraph and returns inferred vector