Skip to content

Instantly share code, notes, and snippets.

@wmlba
Created April 22, 2019 12:17
Show Gist options
  • Save wmlba/e01f8a77b98d8836cd6a8c612bbaf389 to your computer and use it in GitHub Desktop.
Save wmlba/e01f8a77b98d8836cd6a8c612bbaf389 to your computer and use it in GitHub Desktop.
# The code below is from the Keras Blogs
# https://blog.keras.io/building-autoencoders-in-keras.html
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.)
#Print one image to see the noise
plt.imshow(x_test_noisy[1].reshape(28, 28))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment