Mercurial > pylearn
changeset 1301:1a3090eca2ec
make the noise type the same as the input.
author | Frederic Bastien <nouiz@nouiz.org> |
---|---|
date | Fri, 01 Oct 2010 14:42:34 -0400 |
parents | cc1c5720eeca |
children | ca7e4829f6a0 |
files | pylearn/formulas/noise.py |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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