taxi

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

memory_network_adeb.py (1454B)


      1 from blocks.initialization import IsotropicGaussian, Constant
      2 from blocks.algorithms import AdaDelta, CompositeRule, GradientDescent, RemoveNotFinite, StepRule, Momentum
      3 
      4 import data
      5 from model.memory_network import Model, Stream
      6 
      7 
      8 n_begin_end_pts = 5 # how many points we consider at the beginning and end of the known trajectory
      9 
     10 dim_embeddings = [
     11     ('origin_call', data.origin_call_train_size, 10),
     12     ('origin_stand', data.stands_size, 10),
     13     ('week_of_year', 52, 10),
     14     ('day_of_week', 7, 10),
     15     ('qhour_of_day', 24 * 4, 10),
     16     ('day_type', 3, 10),
     17 ]
     18 
     19 
     20 class MLPConfig(object):
     21     __slots__ = ('dim_input', 'dim_hidden', 'dim_output', 'weights_init', 'biases_init')
     22 
     23 prefix_encoder = MLPConfig()
     24 prefix_encoder.dim_input = n_begin_end_pts * 2 * 2 + sum(x for (_, _, x) in dim_embeddings)
     25 prefix_encoder.dim_hidden = [100, 100]
     26 prefix_encoder.weights_init = IsotropicGaussian(0.001)
     27 prefix_encoder.biases_init = Constant(0.0001)
     28 
     29 candidate_encoder = MLPConfig()
     30 candidate_encoder.dim_input = n_begin_end_pts * 2 * 2 + sum(x for (_, _, x) in dim_embeddings)
     31 candidate_encoder.dim_hidden = [100, 100]
     32 candidate_encoder.weights_init = IsotropicGaussian(0.001)
     33 candidate_encoder.biases_init = Constant(0.0001)
     34 
     35 
     36 embed_weights_init = IsotropicGaussian(0.001)
     37 
     38 step_rule = Momentum(learning_rate=0.001, momentum=0.9)
     39 batch_size = 32
     40 
     41 max_splits = 1
     42 num_cuts = 1000
     43 
     44 train_candidate_size = 1000
     45 valid_candidate_size = 10000
     46 
     47 load_model = False