diff options
author | Étienne Simon <esimon@esimon.eu> | 2015-07-02 12:59:15 -0400 |
---|---|---|
committer | Étienne Simon <esimon@esimon.eu> | 2015-07-02 12:59:15 -0400 |
commit | 98139f573eb179c8f5a06ba6c8d8883376814ccf (patch) | |
tree | f27270d80cb91c19639227c921549f762eda2f72 /model/dest_mlp.py | |
parent | a4b190516d00428b1d8a81686a3291e5fa5f9865 (diff) | |
download | taxi-98139f573eb179c8f5a06ba6c8d8883376814ccf.tar.gz taxi-98139f573eb179c8f5a06ba6c8d8883376814ccf.zip |
Remove _simple
Diffstat (limited to 'model/dest_mlp.py')
-rw-r--r-- | model/dest_mlp.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/model/dest_mlp.py b/model/dest_mlp.py new file mode 100644 index 0000000..78d7131 --- /dev/null +++ b/model/dest_mlp.py @@ -0,0 +1,32 @@ +from theano import tensor +from blocks.bricks import application, Identity + +import data +import error +from model.mlp import FFMLP, Stream + + +class Model(FFMLP): + def __init__(self, config, **kwargs): + super(Model, self).__init__(config, output_layer=Identity, **kwargs) + + @application(outputs=['destination']) + def predict(self, **kwargs): + outputs = super(Model, self).predict(**kwargs) + return data.train_gps_std * outputs + data.train_gps_mean + + @predict.property('inputs') + def predict_inputs(self): + return self.inputs + + @application(outputs=['cost']) + def cost(self, **kwargs): + y_hat = self.predict(**kwargs) + y = tensor.concatenate((kwargs['destination_latitude'][:, None], + kwargs['destination_longitude'][:, None]), axis=1) + + return error.erdist(y_hat, y).mean() + + @cost.property('inputs') + def cost_inputs(self): + return self.inputs + ['destination_latitude', 'destination_longitude'] |