diff options
author | Étienne Simon <esimon@esimon.eu> | 2015-07-21 21:08:35 -0400 |
---|---|---|
committer | Étienne Simon <esimon@esimon.eu> | 2015-07-21 21:08:35 -0400 |
commit | 9013799ebca1c426c3c3e9019eb71018b253b025 (patch) | |
tree | b6cdaa6052478ce13204b16b5f42662cd69bd456 /model/bidirectional_tgtcls.py | |
parent | e1673538607a7c8d784013b21b753f0c05c4cc34 (diff) | |
download | taxi-9013799ebca1c426c3c3e9019eb71018b253b025.tar.gz taxi-9013799ebca1c426c3c3e9019eb71018b253b025.zip |
Add bidirectional
Diffstat (limited to 'model/bidirectional_tgtcls.py')
-rw-r--r-- | model/bidirectional_tgtcls.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/model/bidirectional_tgtcls.py b/model/bidirectional_tgtcls.py new file mode 100644 index 0000000..36120f7 --- /dev/null +++ b/model/bidirectional_tgtcls.py @@ -0,0 +1,19 @@ +import numpy +import theano +from theano import tensor +from blocks.bricks.base import lazy +from blocks.bricks import Softmax + +from model.bidirectional import BidiRNN, Stream + + +class Model(BidiRNN): + @lazy() + def __init__(self, config, **kwargs): + super(Model, self).__init__(config, output_dim=config.tgtcls.shape[0], **kwargs) + self.classes = theano.shared(numpy.array(config.tgtcls, dtype=theano.config.floatX), name='classes') + self.softmax = Softmax() + self.children.append(self.softmax) + + def process_outputs(self, outputs): + return tensor.dot(self.softmax.apply(outputs), self.classes) |