def build_sentence_encoder(tparams, options):
 opt_ret = dict()
 trng = RandomStreams(1234)
 x = tensor.matrix('x', dtype='int64')
 mask = tensor.matrix('x_mask', dtype='float32')
 n_timesteps = x.shape[0]
 n_samples = x.shape[1]
 emb = tparams['Wemb'][x.flatten()].reshape([n_timesteps, n_samples, options['dim_word']])
 proj = get_layer(options['encoder'])[1](tparams, emb, None, options, prefix='encoder', mask=mask)
 sents = proj[0][(-1)]
 sents = l2norm(sents)
 return (trng, [x, mask], sents)

def build_sentence_encoder ( tparams , options ) : opt_ret = dict ( ) trng = RandomStreams ( 1234 ) x = tensor . matrix ( 'x' , dtype = 'int64' ) mask = tensor . matrix ( 'x_mask' , dtype = 'float32' ) n_timesteps = x . shape [ 0 ] n_samples = x . shape [ 1 ] emb = tparams [ 'Wemb' ] [ x . flatten ( ) ] . reshape ( [ n_timesteps , n_samples , options [ 'dim_word' ] ] ) proj = get_layer ( options [ 'encoder' ] ) [ 1 ] ( tparams , emb , None , options , prefix = 'encoder' , mask = mask ) sents = proj [ 0 ] [ ( - 1 ) ] sents = l2norm ( sents ) return ( trng , [ x , mask ] , sents )
encoder only .