<jupyter_start><jupyter_text>Denoising<jupyter_code>def add_noise(img,random_chance=5):
    noisy = []
    for row in img:
        new_row = []
        for pix in row:
            if(random.choice(range(100))<= random_chance):
                new_val = random.uniform(0,1)
                new_row.append(new_val)
            else:
                new_row.append(pix)
                
        noisy.append(new_row)
    return np.array(noisy)
noisy=[]
for i in range(10):
    noised = add_noise(x_test[i],10)
    noisy.append(noised)
fig = plt.figure(figsize=(10,10))
columns=3
rows=3
t=0;
for i in range(1,columns*rows+1):
    fig.add_subplot(rows,columns,i)
    plt.imshow(noisy[t],cmap="gray")
    plt.axis("off")
    t+=1
plt.show()

denoised = []
for i in range(10):
    denoised.append(autoencoder.predict([noisy[i].reshape(-1,28,28,1)])[0])

fig = plt.figure(figsize=(10,10))
columns=3
rows=3
t=0;
for i in range(1,columns*rows+1):
    fig.add_subplot(rows,columns,i)
    plt.imshow(denoised[t].reshape((28,28)),cmap="gray")
    plt.axis("off")
    t+=1
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16469517743403095, 'fraction_numerical': 0.039126478616924476, 'mean_word_length': 3.1198501872659175, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '19606', 'license': 'MIT', 'n_tokens_mistral': 461, 'n_tokens_neox': 441, 'n_words': 64, 'path': 'AutoEncoder2.0.ipynb', 'repo_name': 'vedantgoswami/Autoencoder', 'size': '1099'}