如何50%的随机噪声正常添加MNIST数据集在python

问题描述 投票:0回答:1

我试图让嘈杂基于这样的噪音被添加比例的一篇文章MNIST数据集。我不知道如何计算噪声添加到图像的百分比。

这里是我的Python代码:

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的这种噪音50%的比例(基于noise_factor)?噪声系数能告诉我们的百分比是多少?

2.Are有其他的方式与比例增加噪声?

确定性没事儿分布和非随机的同样的事情?我看到他们添加比例的噪声和基于确定性分布,但看上去它和什么都没有的文章。

python noise deterministic
1个回答
0
投票
  1. 噪音是不是按百分比计算。一般情况下,你从一个标准正态分布绘制噪声和你一个因素相乘(在你的情况下,为0.5)
  2. 每当与百分比打交道时,你需要指定相对于多大比例。如果你有,那么你就可以随机从那里汲取(但是我还没有看到它在实践中)。
  3. 提供更多的信息,但如果事情是确定的,这意味着它是不随机的。它可以让你的随机模型确定通过指定一个种子值,但这通常是到实验之间产生完全相同的随机值。
© www.soinside.com 2019 - 2024. All rights reserved.