From dd8ae5ea8ed0c7cb1a7880b1e1887c6e23cdf910 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 23 Jul 2015 10:07:38 -0400 Subject: Fix RNN prediction function --- model/rnn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/rnn.py b/model/rnn.py index bfc3122..0ee9586 100644 --- a/model/rnn.py +++ b/model/rnn.py @@ -99,7 +99,7 @@ class RNN(Initializable): res = self.predict_all(**kwargs)[0] last_id = tensor.cast(kwargs['latitude_mask'].sum(axis=0) - 1, dtype='int64') - return res[last_id] + return res[last_id, tensor.arange(kwargs['latitude_mask'].shape[1])] @predict.property('inputs') def predict_inputs(self): @@ -134,7 +134,7 @@ class RNN(Initializable): @application(outputs=['cost']) def valid_cost(self, **kwargs): last_id = tensor.cast(kwargs['latitude_mask'].sum(axis=1) - 1, dtype='int64') - return self.cost_matrix(**kwargs)[last_id].mean() + return self.cost_matrix(**kwargs)[last_id, tensor.arange(kwargs['latitude_mask'].shape[1])].mean() @valid_cost.property('inputs') def valid_cost_inputs(self): -- cgit v1.2.3