changeset 790:d98117100166

fix FillMissing debug mode error. The error was caused by the fact that debug_mode generate an error by default for NaN value. We must disable this check for this op as we deal with NaN value.
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Fri, 10 Jul 2009 12:16:20 -0400
parents 7a65c5b79aca
children 166a89917669
files pylearn/sandbox/test_scan_inputs_groups.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/sandbox/test_scan_inputs_groups.py	Fri Jul 10 11:31:32 2009 -0400
+++ b/pylearn/sandbox/test_scan_inputs_groups.py	Fri Jul 10 12:16:20 2009 -0400
@@ -1,4 +1,4 @@
-import sys, time, unittest
+import sys, time, unittest, copy
 
 import numpy,time
 import numpy as N
@@ -8,18 +8,27 @@
 from theano import function, Mode
 import theano.tensor as T
 from pylearn.sandbox.scan_inputs_groups import FillMissing
+import theano.compile.mode as mode_module
 
 class TestFillMissing(unittest.TestCase):
     def setUp(self):
         utt.seed_rng()
 
+        #we need to desactivate the check for NaN value as we have them in input
+        #TODO: Make an option to don't check NaN value in input only, bug check in output.
+        m=mode_module.default_mode
+        if m=="DEBUG_MODE":
+            m=copy.copy(mode_module.predefined_modes[m])
+            m.check_isfinite=False
+        self.mode = m
+
     def test_vector(self):
         print "test_vector"
         n=100000
         v=T.dvector()
         def t(prob,val,fill):
             op=FillMissing(fill)(v)
-            f=function([v],op)
+            f=function([v],op,mode=self.mode)
             nb_missing=0
             for i in range(n):
                 if prob[i]<0.1:
@@ -54,7 +63,7 @@
         v=T.dmatrix()
         def t(prob,val,fill):
             op=FillMissing(fill)(v)
-            f=function([v],op)
+            f=function([v],op,mode=self.mode)
         
             nb_missing=0
             for i in range(shp[0]):
@@ -92,7 +101,7 @@
         shp=(10,100,100)
         v= T.TensorType('float64', (False, False, False))()
         op=FillMissing()(v)
-        fct=function([v],op)
+        fct=function([v],op,mode=self.mode)
         
         prob=N.random.random(N.prod(shp)).reshape(shp)
         val=N.random.random(prob.shape)