aboutsummaryrefslogtreecommitdiff
path: root/model/memory_network_mlp.py
diff options
context:
space:
mode:
Diffstat (limited to 'model/memory_network_mlp.py')
-rw-r--r--model/memory_network_mlp.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/model/memory_network_mlp.py b/model/memory_network_mlp.py
index de07e60..fc897d5 100644
--- a/model/memory_network_mlp.py
+++ b/model/memory_network_mlp.py
@@ -18,17 +18,17 @@ from memory_network import MemoryNetworkBase
class MLPEncoder(Initializable):
def __init__(self, config, output_dim, activation, **kwargs):
- super(RecurrentEncoder, self).__init__(**kwargs)
+ super(MLPEncoder, self).__init__(**kwargs)
self.config = config
self.context_embedder = ContextEmbedder(self.config)
- self.encoder_mlp = MLP(activations=[Rectifier() for _ in config.prefix_encoder.dim_hidden]
- + [config.representation_activation()],
- dims=[config.prefix_encoder.dim_input]
- + config.prefix_encoder.dim_hidden
- + [config.representation_size],
- name='prefix_encoder')
+ self.encoder_mlp = MLP(activations=[Rectifier() for _ in config.dim_hidden]
+ + [activation()],
+ dims=[config.dim_input]
+ + config.dim_hidden
+ + [output_dim],
+ name='encoder')
self.extremities = {'%s_k_%s' % (side, ['latitude', 'longitude'][axis]): axis
for side in ['first', 'last'] for axis in [0, 1]}
@@ -37,7 +37,7 @@ class MLPEncoder(Initializable):
self.encoder_mlp ]
def _push_initialization_config(self):
- for brick in [self.contex_encoder, self.encoder_mlp]:
+ for brick in [self.context_embedder, self.encoder_mlp]:
brick.weights_init = self.config.weights_init
brick.biases_init = self.config.biases_init
@@ -46,7 +46,7 @@ class MLPEncoder(Initializable):
embeddings = tuple(self.context_embedder.apply(
**{k: kwargs[k] for k in self.context_embedder.inputs }))
extremities = tuple((kwargs[k] - data.train_gps_mean[v]) / data.train_gps_std[v]
- for k, v in self.prefix_extremities.items())
+ for k, v in self.extremities.items())
inputs = tensor.concatenate(extremities + embeddings, axis=1)
return self.encoder_mlp.apply(inputs)
@@ -60,12 +60,12 @@ class Model(MemoryNetworkBase):
def __init__(self, config, **kwargs):
prefix_encoder = MLPEncoder(config.prefix_encoder,
config.representation_size,
- config.representation_activation())
+ config.representation_activation,
+ name='prefix_encoder')
- candidate_encoer = MLPEncoder(config.candidate_encoder,
+ candidate_encoder = MLPEncoder(config.candidate_encoder,
config.representation_size,
- config.representation_activation())
+ config.representation_activation,
+ name='candidate_encoder')
super(Model, self).__init__(config, prefix_encoder, candidate_encoder, **kwargs)
-
-