annotate noise.py @ 428:52b4908d8971

simple example of theano
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Fri, 25 Jul 2008 16:59:57 -0400
parents 643dbccde1fc
children
rev   line source
414
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
1 def binomial(input, rstate, p = 0.75):
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
2 """
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
3 Op to corrupt an input with binomial noise.
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
4 Generate a noise vector of 1's and 0's (1 with probability p).
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
5 We multiply this by the input.
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
6
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
7 @note: See U{ssh://projects@lgcm.iro.umontreal.ca/repos/denoising_aa}
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
8 to see how rstate is used.
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
9 """
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
10 noise = rstate.gen_like(('binomial',{'p': p, 'n': 1}), input)
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
11 noise.name = 'noise'
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
12 return noise * input
643dbccde1fc Added noise functions
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
13