changeset 1469:c41fdf8c35b8

fix about floatX=float32 to remove error in the build bot.
author Frederic Bastien <nouiz@nouiz.org>
date Wed, 27 Apr 2011 11:34:36 -0400
parents cac29ca79a74
children a57f4839a9d8 e7c4d031d333
files pylearn/algorithms/aa.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/aa.py	Wed Apr 27 10:43:04 2011 -0400
+++ b/pylearn/algorithms/aa.py	Wed Apr 27 11:34:36 2011 -0400
@@ -2,6 +2,8 @@
 import theano
 from theano import tensor as T
 from theano.tensor import nnet as NN
+floatX = theano.config.floatX
+
 import numpy as N
 
 class AutoEncoder(theano.Module):
@@ -73,11 +75,15 @@
         if input_size is not None:
             sz = (input_size, hidden_size)
             range = 1/N.sqrt(input_size)
-            obj.w1 = R.uniform(size = sz, low = -range, high = range)
+            if floatX=='float32':
+                range = N.float32(range)
+            obj.w1 = N.asarray(R.uniform(size = sz, low = -range, high = range),
+                               dtype=floatX)
             if not self.tie_weights:
-                obj.w2 = R.uniform(size = list(reversed(sz)), low = -range, high = range)
-            obj.b1 = N.zeros(hidden_size)
-            obj.b2 = N.zeros(input_size)
+                obj.w2 = N.asarray(R.uniform(size = list(reversed(sz)), low = -range, high = range),
+                                   dtype=floatX)
+            obj.b1 = N.zeros(hidden_size, dtype=floatX)
+            obj.b2 = N.zeros(input_size, dtype=floatX)
 
     def build_regularization(self):
         return T.zero() # no regularization!