(clf, w2v_W, w2v_vocab, orig_word_vectors, word_idict)
return init_embed.get()
Map words from word2vec into RNN word space

    Function modifed from:
    https://github.com/ryankiros/skip-thoughts/blob/master/training/tools.py
Map words from word2vec into RNN word space
Map words from word2vec into RNN word space
def apply_regressor(clf, w2v_W, w2v_vocab, orig_word_vectors, word_idict):
    """
    Map words from word2vec into RNN word space

    Function modifed from:
    https://github.com/ryankiros/skip-thoughts/blob/master/training/tools.py
    """
    init_embed = clf.be.zeros((len(w2v_vocab), 620), dtype=np.float32)

    word_vec = clf.be.empty((300, 1))

    # to apply the regression model for expansion, can only do one word at a time
    # so to set the actual batch_size to be 1
    actual_bsz = 1
    clf.set_batch_size(N=actual_bsz)

    for i, w in enumerate(w2v_vocab.keys()):
        word_vec.set(w2v_W[w2v_vocab[w]].reshape(300, 1))
        init_embed[w2v_vocab[w]][:] = clf.fprop(word_vec)[:, :actual_bsz]

    word_vec_l = clf.be.empty((620, 1))
    for w in word_idict.values():
        if w in w2v_vocab:
            word_vec_l.set(orig_word_vectors[w])
            init_embed[w2v_vocab[w]][:] = word_vec_l

    return init_embed.get()
def apply_regressor ( clf , w2v_W , w2v_vocab , orig_word_vectors , word_idict ) : init_embed = clf . be . zeros ( ( len ( w2v_vocab ) , 620 ) , dtype = np . float32 ) word_vec = clf . be . empty ( ( 300 , 1 ) ) # to apply the regression model for expansion, can only do one word at a time # so to set the actual batch_size to be 1 actual_bsz = 1 clf . set_batch_size ( N = actual_bsz ) for i , w in enumerate ( w2v_vocab . keys ( ) ) : word_vec . set ( w2v_W [ w2v_vocab [ w ] ] . reshape ( 300 , 1 ) ) init_embed [ w2v_vocab [ w ] ] [ : ] = clf . fprop ( word_vec ) [ : , : actual_bsz ] word_vec_l = clf . be . empty ( ( 620 , 1 ) ) for w in word_idict . values ( ) : if w in w2v_vocab : word_vec_l . set ( orig_word_vectors [ w ] ) init_embed [ w2v_vocab [ w ] ] [ : ] = word_vec_l return init_embed . get ( )