changeset 516:2b0e10ac6929

misc
author Olivier Breuleux <breuleuo@iro.umontreal.ca>
date Mon, 03 Nov 2008 00:10:18 -0500
parents dc2d93590da0
children 716c04512dbe b267a8000f92
files algorithms/regressor.py algorithms/stacker.py
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/algorithms/regressor.py	Fri Oct 31 16:37:19 2008 -0400
+++ b/algorithms/regressor.py	Mon Nov 03 00:10:18 2008 -0500
@@ -45,6 +45,7 @@
 
         # INTERFACE METHODS
         self.update = theano.Method([self.input, self.target], self.cost, updates)
+        self.get_cost = theano.Method([self.input, self.target], self.cost)
         self.predict = theano.Method(self.input, self.output)
 
         self.build_extensions()
--- 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]