Mercurial > pylearn
comparison pylearn/algorithms/aa.py @ 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 | ba65e95d1221 |
children |
comparison
equal
deleted
inserted
replaced
1468:cac29ca79a74 | 1469:c41fdf8c35b8 |
---|---|
1 | 1 |
2 import theano | 2 import theano |
3 from theano import tensor as T | 3 from theano import tensor as T |
4 from theano.tensor import nnet as NN | 4 from theano.tensor import nnet as NN |
5 floatX = theano.config.floatX | |
6 | |
5 import numpy as N | 7 import numpy as N |
6 | 8 |
7 class AutoEncoder(theano.Module): | 9 class AutoEncoder(theano.Module): |
8 | 10 |
9 def __init__(self, input = None, regularize = True, tie_weights = True): | 11 def __init__(self, input = None, regularize = True, tie_weights = True): |
71 else: | 73 else: |
72 R = N.random | 74 R = N.random |
73 if input_size is not None: | 75 if input_size is not None: |
74 sz = (input_size, hidden_size) | 76 sz = (input_size, hidden_size) |
75 range = 1/N.sqrt(input_size) | 77 range = 1/N.sqrt(input_size) |
76 obj.w1 = R.uniform(size = sz, low = -range, high = range) | 78 if floatX=='float32': |
79 range = N.float32(range) | |
80 obj.w1 = N.asarray(R.uniform(size = sz, low = -range, high = range), | |
81 dtype=floatX) | |
77 if not self.tie_weights: | 82 if not self.tie_weights: |
78 obj.w2 = R.uniform(size = list(reversed(sz)), low = -range, high = range) | 83 obj.w2 = N.asarray(R.uniform(size = list(reversed(sz)), low = -range, high = range), |
79 obj.b1 = N.zeros(hidden_size) | 84 dtype=floatX) |
80 obj.b2 = N.zeros(input_size) | 85 obj.b1 = N.zeros(hidden_size, dtype=floatX) |
86 obj.b2 = N.zeros(input_size, dtype=floatX) | |
81 | 87 |
82 def build_regularization(self): | 88 def build_regularization(self): |
83 return T.zero() # no regularization! | 89 return T.zero() # no regularization! |
84 | 90 |
85 | 91 |