diff options
Diffstat (limited to 'model/time_simple_mlp.py')
-rw-r--r-- | model/time_simple_mlp.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/model/time_simple_mlp.py b/model/time_simple_mlp.py index 1568ed3..9e1b10a 100644 --- a/model/time_simple_mlp.py +++ b/model/time_simple_mlp.py @@ -1,8 +1,6 @@ from blocks.bricks import MLP, Rectifier, Linear, Sigmoid, Identity from blocks.bricks.lookup import LookupTable -from blocks.initialization import IsotropicGaussian, Constant - from theano import tensor import data @@ -11,11 +9,11 @@ import error class Model(object): def __init__(self, config): # The input and the targets - x_firstk_latitude = (tensor.matrix('first_k_latitude') - data.porto_center[0]) / data.data_std[0] - x_firstk_longitude = (tensor.matrix('first_k_longitude') - data.porto_center[1]) / data.data_std[1] + x_firstk_latitude = (tensor.matrix('first_k_latitude') - data.train_gps_mean[0]) / data.train_gps_std[0] + x_firstk_longitude = (tensor.matrix('first_k_longitude') - data.train_gps_mean[1]) / data.train_gps_std[1] - x_lastk_latitude = (tensor.matrix('last_k_latitude') - data.porto_center[0]) / data.data_std[0] - x_lastk_longitude = (tensor.matrix('last_k_longitude') - data.porto_center[1]) / data.data_std[1] + x_lastk_latitude = (tensor.matrix('last_k_latitude') - data.train_gps_mean[0]) / data.train_gps_std[0] + x_lastk_longitude = (tensor.matrix('last_k_longitude') - data.train_gps_mean[1]) / data.train_gps_std[1] input_list = [x_firstk_latitude, x_firstk_longitude, x_lastk_latitude, x_lastk_longitude] embed_tables = [] @@ -29,7 +27,7 @@ class Model(object): embed_tables.append(tbl) input_list.append(tbl.apply(vardata)) - y = tensor.lvector('time') + y = tensor.lvector('travel_time') # Define the model mlp = MLP(activations=[Rectifier() for _ in config.dim_hidden] + [Identity()], @@ -38,7 +36,7 @@ class Model(object): # Create the Theano variables inputs = tensor.concatenate(input_list, axis=1) # inputs = theano.printing.Print("inputs")(inputs) - outputs = tensor.exp(mlp.apply(inputs) + 2) + outputs = config.exp_base ** mlp.apply(inputs) # outputs = theano.printing.Print("outputs")(outputs) # y = theano.printing.Print("y")(y) @@ -51,9 +49,9 @@ class Model(object): # Initialization for tbl in embed_tables: - tbl.weights_init = IsotropicGaussian(0.001) - mlp.weights_init = IsotropicGaussian(0.01) - mlp.biases_init = Constant(0.001) + tbl.weights_init = config.embed_weights_init + mlp.weights_init = config.mlp_weights_init + mlp.biases_init = config.mlp_biases_init for tbl in embed_tables: tbl.initialize() @@ -62,4 +60,4 @@ class Model(object): self.cost = cost self.monitor = [cost] self.outputs = outputs - self.pred_vars = ['time'] + self.pred_vars = ['travel_time'] |