# HG changeset patch # User Frederic Bastien # Date 1285958554 14400 # Node ID 1a3090eca2ecd2d1cf635cee0af4016f6f4cdc13 # Parent cc1c5720eeca4e87388d1fd5b941148225c30252 make the noise type the same as the input. diff -r cc1c5720eeca -r 1a3090eca2ec pylearn/formulas/noise.py --- a/pylearn/formulas/noise.py Fri Oct 01 12:56:06 2010 -0400 +++ b/pylearn/formulas/noise.py Fri Oct 01 14:42:34 2010 -0400 @@ -37,8 +37,7 @@ size = inp.shape, n = 1, p = 1 - noise_lvl, - dtype=theano.config.floatX) - # QUESTION: should the dtype not default to the input dtype? + dtype=inp.dtype) return mask * input @@ -51,8 +50,9 @@ :type noise_lvl: tuple(float,float) :param noise_lvl: The %% of noise for the salt and pepper. Between 0 (no noise) and 1. """ - return theano_rng.binomial( size = inp.shape, n = 1, p = 1 - noise_lvl[0], dtype=theano.config.floatX) * inp \ - + (inp==0) * theano_rng.binomial( size = inp.shape, n = 1, p = noise_lvl[1], dtype=theano.config.floatX) + assert inp.dtype in ['float32','float64'] + return theano_rng.binomial( size = inp.shape, n = 1, p = 1 - noise_lvl[0], dtype=inp.dtype) * inp \ + + (inp==0) * theano_rng.binomial( size = inp.shape, n = 1, p = noise_lvl[1], dtype=inp.dtype) @tags.tags('noise','gauss','gaussian') def gaussian_noise(theano_rng,inp,noise_lvl): @@ -63,4 +63,5 @@ :type noise_lvl: float :param noise_lvl: The standard deviation of the gaussian. """ - return theano_rng.normal( size = inp.shape, std = noise_lvl, dtype=theano.config.floatX) + inp + assert inp.dtype in ['float32','float64'] + return theano_rng.normal( size = inp.shape, std = noise_lvl, dtype=inp.dtype) + inp