build an encoder, given pre-computed word embeddings
(tparams, options)
| 284 | |
| 285 | |
| 286 | def build_encoder(tparams, options): |
| 287 | """ |
| 288 | build an encoder, given pre-computed word embeddings |
| 289 | """ |
| 290 | # word embedding (source) |
| 291 | embedding = tensor.tensor3('embedding', dtype='float32') |
| 292 | x_mask = tensor.matrix('x_mask', dtype='float32') |
| 293 | |
| 294 | # encoder |
| 295 | proj = get_layer(options['encoder'])[1](tparams, embedding, options, |
| 296 | prefix='encoder', |
| 297 | mask=x_mask) |
| 298 | ctx = proj[0][-1] |
| 299 | |
| 300 | return embedding, x_mask, ctx |
| 301 | |
| 302 | |
| 303 | def build_encoder_bi(tparams, options): |
no test coverage detected