# HG changeset patch # User David Warde-Farley # Date 1285948504 14400 # Node ID b9bc9d5a08cc5e1838bef823173e7fcc2c9d61cf # Parent 7af2a89bff3d16f1e51f83f11d6fee06c66f58e5 Some language fixes (don't capitalize 'variable', changement->change. diff -r 7af2a89bff3d -r b9bc9d5a08cc pylearn/formulas/noise.py --- a/pylearn/formulas/noise.py Fri Oct 01 11:47:53 2010 -0400 +++ b/pylearn/formulas/noise.py Fri Oct 01 11:55:04 2010 -0400 @@ -2,8 +2,8 @@ This script define the different symbolic noise functions. The noise contract is simple: noise_lvl is a symbolic variable going from 0 to 1. -0: no changement. -1: max noise. +0: no change. +1: maximum noise. """ import theano from tags import tags @@ -21,12 +21,13 @@ @tags('noise','binomial','salt') def binomial_noise(theano_rng,inp,noise_lvl): - """ This add binomial noise to inp. Only the salt part of pepper and salt. + """ + This add binomial noise to inp. Only the salt part of pepper and salt. - :type inp: Theano Variable + :type inp: Theano variable :param inp: The input that we want to add noise :type noise_lvl: float - :param noise_lvl: The % of noise. Between 0(no noise) and 1. + :param noise_lvl: The %% of noise. Between 0 (no noise) and 1. """ return theano_rng.binomial( size = inp.shape, n = 1, p = 1 - noise_lvl, dtype=theano.config.floatX) * inp @@ -34,11 +35,11 @@ @tags('noise','binomial NLP','pepper','salt') def pepper_and_salt_noise(theano_rng,inp,noise_lvl): """ This add pepper and salt noise to inp - - :type inp: Theano Variable + + :type inp: Theano variable :param inp: The input that we want to add noise :type noise_lvl: tuple(float,float) - :param noise_lvl: The % of noise for the salt and pepper. Between 0(no noise) and 1. + :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) @@ -47,7 +48,7 @@ def gaussian_noise(theano_rng,inp,noise_lvl): """ This add gaussian NLP noise to inp - :type inp: Theano Variable + :type inp: Theano variable :param inp: The input that we want to add noise :type noise_lvl: float :param noise_lvl: The standard deviation of the gaussian.