<jupyter_start><jupyter_text>Noise Removal Autoencoder<jupyter_code>import tensorflow as tf
# Encoder

tf.random.set_seed(101)
np.random.seed(101)

encoder = Sequential()
encoder.add(Flatten(input_shape=[28,28]))

encoder.add(GaussianNoise(0.2))

encoder.add(Dense(400,activation='relu'))
encoder.add(Dense(200,activation='relu'))
encoder.add(Dense(100,activation='relu'))
encoder.add(Dense(50,activation='relu'))
encoder.add(Dense(25,activation='relu'))
# Decoder
decoder = Sequential()
decoder.add(Dense(50,input_shape=[25],activation='relu'))
decoder.add(Dense(100,activation='relu'))
decoder.add(Dense(200,activation='relu'))
decoder.add(Dense(400,activation='relu'))
decoder.add(Dense(784,activation='sigmoid'))
decoder.add(Reshape([28,28]))
noise_remover = Sequential([encoder, decoder])
noise_remover.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
noise_remover.fit(X_train,X_train,epochs=10)
ten_noisey_images = sample(X_test[:10], training=True)
denoised_images = noise_remover(ten_noisey_images)
n = 6

print('Original Image')
plt.imshow(X_test[n])
plt.show()

print('After Noise Added')
plt.imshow(ten_noisey_images[n])
plt.show()

print('After Noise Removal')
plt.imshow(denoised_images[n])
plt.show()<jupyter_output>Original Image
{'fraction_non_alphanumeric': 0.17059748427672955, 'fraction_numerical': 0.03930817610062893, 'mean_word_length': 12.123711340206185, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '243543', 'license': 'MIT', 'n_tokens_mistral': 536, 'n_tokens_neox': 475, 'n_words': 56, 'path': 'Classification.ipynb', 'repo_name': 'rooneyrulz/mnist-autoencoder', 'size': '1272'}