taxi

Winning entry to the Kaggle taxi competition
git clone https://esimon.eu/repos/taxi.git
Log | Files | Refs | README

bidirectional_tgtcls.py (673B)


      1 import numpy
      2 import theano
      3 from theano import tensor
      4 from blocks.bricks.base import lazy
      5 from blocks.bricks import Softmax
      6 
      7 from model.bidirectional import BidiRNN, Stream
      8 
      9 
     10 class Model(BidiRNN):
     11     @lazy()
     12     def __init__(self, config, **kwargs):
     13         super(Model, self).__init__(config, output_dim=config.tgtcls.shape[0], **kwargs)
     14 
     15         self.classes = theano.shared(numpy.array(config.tgtcls, dtype=theano.config.floatX),
     16                                      name='classes')
     17         self.softmax = Softmax()
     18         self.children.append(self.softmax)
     19 
     20     def process_outputs(self, outputs):
     21         return tensor.dot(self.softmax.apply(outputs), self.classes)
     22