CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Add noise to the input feature for Generalization of Neural Networks in CNTK

Open mosayyebpour opened this issue 10 years ago • 5 comments

I have one question. One way of helping the Neural Network to better generalize for new data is to add random noise at each epoch of training to the input feature at the input layer. Is it possible to do it using CNTK?

mosayyebpour avatar Sep 13 '16 19:09 mosayyebpour

We are working on a random generator for exactly this purpose, but as of today, there is no good solution available yet.

You could wing it partially by mis-appropriating the dropout operation, which gives you binary random numbers. A crude approximation to a bell curve could be to sum up a handful of these binary random numbers. I have not tried it, but something like this:

AddNoise (x, sc) = {  # adds noise; choose sc to match your desired variance
    ones = x .* 0 + 1  # tensor of ones of same size as the input feature
    rands[i:0..7] = Dropout (ones)  # 8 dropout versions thereof
    noise = sc .* (rands[0] + rands[1] + rands[2] + rands[3] + rands[4] + rands[5] + rands[6] + rands[7] - 3.5)
    xpn = x + noise
}.xpn

If you try it, please do let me know if this works :)

frankseide avatar Sep 13 '16 20:09 frankseide

Thanks Frank,

So please let me know in this post when this option is ready to use in CNTK. Because I believe this helps a lot for better generalization.

mosayyebpour avatar Sep 13 '16 20:09 mosayyebpour

Looping in @thilow as well. If you don't hear from me within 1..2 weeks, feel free to ping.

frankseide avatar Sep 13 '16 22:09 frankseide

Hey Frank,

I am following up regarding your last comment about adding noise to the input feature. Do you have any update for me?

By the way I have tried what you said but I got this error. " Parameter name could not be resolved 'featNoisy' "

Here is what I wrote for my NetworkDescription :

    featIn=Input(featInDim, tag=feature)
myLabel=Input(labelDim, tag=feature)
					       			       
 # define network
    ones=featIn*0+1
 rands[i:0..7] = Dropout(ones)
 noise = (rands[0] + rands[1] + rands[2] + rands[3] + rands[4] + rands[5] + rands[6] + rands[7] - 3.5)
 featNoisy=featIn+noise 

 B=Parameter(hiddenDim, init=fixedvalue, value=0)
    W=Parameter(hiddenDim, featInDim, init=Uniform, initValueScale=1)	 

    T=Times(W,featNoisy)
 P=Plus(T, B)
     Layer1 = Tanh(P).... and so on

If I replace "T=Times(W,featNoisy)" with T=Times(W,featIn), then there is no problem. Do you know what is the problem?

mosayyebpour avatar Nov 23 '16 21:11 mosayyebpour

In latest CNTK you may add noise to input with numpy, or use cntk.random.

Since this issue is very old I'm closing it.

cha-zhang avatar Jul 15 '17 00:07 cha-zhang