annotate misc.py @ 183:25d0a0c713da

did some debugging of test_mlp
author Olivier Breuleux <breuleuo@iro.umontreal.ca>
date Tue, 13 May 2008 18:30:08 -0400
parents e9a95e19e6f8
children d7250ee86f72
rev   line source
175
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
1
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
2 import theano
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
3
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
4 class Print(theano.Op):
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
5 def __init__(self,message=""):
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
6 self.message=message
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
7 self.view_map={0:[0]}
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
8
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
9 def make_node(self,xin):
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
10 xout = xin.type.make_result()
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
11 return theano.Apply(op = self, inputs = [xin], outputs=[xout])
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
12
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
13 def perform(self,node,inputs,output_storage):
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
14 xin, = inputs
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
15 xout, = output_storage
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
16 xout[0] = xin
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
17 print self.message,xin
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
18
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
19 def grad(self,input,output_gradients):
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
20 return output_gradients
e9a95e19e6f8 Added a Print Op
Yoshua Bengio <bengioy@iro.umontreal.ca>
parents: 49
diff changeset
21
49
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
22
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
23 def unique_elements_list_intersection(list1,list2):
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
24 """
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
25 Return the unique elements that are in both list1 and list2
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
26 (repeated elements in listi will not be duplicated in the result).
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
27 This should run in O(n1+n2) where n1=|list1|, n2=|list2|.
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
28 """
718befdc8671 Miscellaneous general-purpose functions
bengioy@grenat.iro.umontreal.ca
parents:
diff changeset
29 return list(set.intersection(set(list1),set(list2)))