diff algorithms/stacker.py @ 516:2b0e10ac6929

misc
author Olivier Breuleux <breuleuo@iro.umontreal.ca>
date Mon, 03 Nov 2008 00:10:18 -0500
parents c7ce66b4e8f4
children
line wrap: on
line diff
--- a/algorithms/stacker.py	Fri Oct 31 16:37:19 2008 -0400
+++ b/algorithms/stacker.py	Mon Nov 03 00:10:18 2008 -0500
@@ -1,3 +1,9 @@
+
+# for example in examples:
+#     repr = example
+#     for layer in stacked.layers:
+#         layer.update(repr)
+#         repr = layer.representation(repr)
 
 import theano
 from theano import tensor as T
@@ -24,11 +30,12 @@
         self.input = self.layers[0].input
         self.output = current
 
+        representation = []
         local_update = []
         global_update = []
         to_update = []
         all_kits = []
-        for layer in layers:
+        for layer, (submodule, outname) in zip(layers, submodules):
             u = layer.update
             u.resolve_all()
             to_update += u.updates.keys()
@@ -46,12 +53,14 @@
                               dict((param, param - layer.lr * T.grad(layer.cost, param))
                                    for param in to_update),
                               list(all_kits)))
+            representation.append(theano.Method(self.input, layer[outname]))
 
 #           @todo: Add diagnostics
 #             self.diagnose_from_input = Method([self.input], self.layers[0].diagnose.outputs + self.layers[1].diagnose.outputs ...
 
         self.local_update = local_update
         self.global_update = global_update
+        self.representation = representation
         self.update = self.global_update[-1]
         self.compute = theano.Method(self.input, self.output)
         ll = self.layers[-1]