annotate misc_theano.py @ 433:200a5b0e24ea

Example showing parameter updates.
author Pascal Lamblin <lamblinp@iro.umontreal.ca>
date Thu, 31 Jul 2008 17:25:35 -0400
parents 2480024bf401
children
rev   line source
327
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
1
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
2 import theano
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
3
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
4 class Print(theano.Op):
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
5 def __init__(self,message=""):
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
6 self.message=message
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
7 self.view_map={0:[0]}
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
8
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
9 def make_node(self,xin):
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
10 xout = xin.type.make_result()
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
11 return theano.Apply(op = self, inputs = [xin], outputs=[xout])
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
12
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
13 def perform(self,node,inputs,output_storage):
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
14 xin, = inputs
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
15 xout, = output_storage
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
16 xout[0] = xin
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
17 print self.message,xin
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
18
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
19 def grad(self,input,output_gradients):
2480024bf401 added file that was missing in commit 9e96fe8b955c
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
diff changeset
20 return output_gradients