gt_array = [38.28, 236.86, 96.498, 187.41, 125.21, 131.59, 154.72, 78.156,
198.58, 42.268, 121.22, 145.94, 157.11, 106.07, 196.98, 98.891,
236.06, 94.903, 115.64, 177.05, 157.91, 157.11, 186.62, 147.54,
224.9, 145.94, 115.64, 202.57, 161.1, 189.81, 189.81, 185.02,
224.9, 183.43, 112.45, 228.88, 153.12, 236.86, 180.24, 241.64,
204.96, 245.63]
I have this training data. I want to add zero value to some data in training to get better model with denoising. I know like this one:
noise_factor = 0.5
input_noisy = gt_array + noise_factor * np.random.normal(loc = 0.0, scale = 1.0 , size = gt_array.shape)
But I want to get randomly zero noise in training data? How can I do that?
Use random choice to get a set of indices based on the proportion and finally set those to 0.
zero_noise_proportion = 0.3 # 30% of the data
indices = np.random.choice(np.arange(gt_array.size),
replace=False,
size=int(gt_array.size * zero_noise_proportion))
gt_array[indices] = 0