commit 8792dd327159b6eebbca167c325629b42e54766f
parent 6d5dd44c5b6c6e0f7eecc5997b484b40f35c0074
Author: Étienne Simon <esimon@esimon.eu>
Date: Thu, 23 Jul 2015 15:13:15 -0400
Fix bidirectional
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/model/bidirectional.py b/model/bidirectional.py
@@ -59,9 +59,10 @@ class BidiRNN(Initializable):
longitude = tensor.shape_padright(longitude)
rec_in = tensor.concatenate((latitude, longitude), axis=2)
+ last_id = tensor.cast(latitude_mask.sum(axis=0) - 1, dtype='int64')
path = self.rec.apply(self.fork.apply(rec_in), mask=latitude_mask)[0]
path_representation = (path[0][:, -self.config.hidden_state_dim:],
- path[-1][:, :self.config.hidden_state_dim])
+ path[last_id - 1, tensor.arange(latitude_mask.shape[1])][:, :self.config.hidden_state_dim])
embeddings = tuple(self.context_embedder.apply(**{k: kwargs[k] for k in self.context_embedder.inputs }))