0

I'm trying to make the MNIST dataset noisy based on an article where noises were added by percentage. I don't know how to calculate the percentage of noise added to an image.

Here is my Python code:

from keras.datasets import mnist
import numpy as np

(X_train, y_train), (X_test, y_test) = mnist.load_data()
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255
noise_factor = 0.5
x_train_noisy = X_train + noise_factor * np.random.normal(loc=0.0, scale=1.0, size=X_train.shape) 
x_test_noisy = X_test + noise_factor * np.random.normal(loc=0.0, scale=1.0, size=X_test.shape) 
x_train_noisy = np.clip(x_train_noisy, 0., 1.)
x_test_noisy = np.clip(x_test_noisy, 0., 1.)

1.Is the percentage of this noise 50% (based on noise_factor)? Can noise factor show us the percentage?

2.Are there other ways to add noise with percentage?

3.Are deterministic distribution and non-random same things? I saw an article where they added noise with percentage and based on deterministic distribution but looked for it and got nothing.

Josh Friedlander
  • 10,870
  • 5
  • 35
  • 75

1 Answers1

1
  1. The noise is not in terms of percentage. Generally , you draw noise from a standard normal distribution and you multiply it with a factor (in your case, it is .5)

  2. Whenever dealing with percentages, you need to specify percentage with respect to what. If you have that , then you can draw randomly from there (however i have not seen it in practice).

  3. Provide more info , but if something is deterministic, it means it is non random. It is possible to make your random model deterministic by specifying a seed value, but this is usually to produce exact same random values between experiments.

harveyslash
  • 5,906
  • 12
  • 58
  • 111
  • So how do people usually specify it?Can you name some? – mahyar sadeghi Feb 07 '19 at 11:30
  • they draw from a normal distribution. the amount is varied by selecting the variance of the distribution (or they just draw from standard normal distribution and multiply it by a factor) – harveyslash Feb 07 '19 at 11:31
  • and by the way, this is that article that i'm talking about.they use percentage but they didn't mension how to calculate it.https://ieeexplore.ieee.org/document/8079976 – mahyar sadeghi Feb 07 '19 at 11:31
  • I would say its simply the strength of the gaussian. so you can multiply the standard normal by .5 (like you have) – harveyslash Feb 07 '19 at 11:38
  • @mahyarsadeghi You have an answer in your other question explaining what they probably did to add the noise. You didn't ask for clarifications so I assume you understood the answer. Why are you asking the same again? – Stop harming Monica Feb 07 '19 at 11:46