Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Predicting Noisy Images - Add Noise to the Data

In this step, we will add noise to the images. We would use the randint function to generate the noise and then add the noise to the train and test set. Finally, we would store this noisy data in 2 new variables called X_train_mod and X_test_mod.

  1. Import random module as rnd:

    import numpy.<< your code goes here >> as rnd
  2. Generate the noise and store the noisy data into the new variables:

    noise_train = rnd.randint(0, 100, (len(X_train), 784))
    X_train_mod = X_train + noise_train
    noise_test = rnd.randint(0, 100, (len(X_test), 784))
    X_test_mod = X_test + << your code goes here >>
    y_train_mod = X_train
    y_test_mod = X_test

    If you notice the code, the first line generates the noise by using the randint() function. The randint() function takes 4 inputs:

    • low
    • high
    • size
    • dtype

    Here, low and high gives the range of the distribution, whereas size defines the output shape, and finally, dtype specifies the data type. It gives an array of integers as an output. Next we add this noise to the X-train and X_test datasets. Finally, we create a new set of labels, these labels are the original images. The model we will create will predict these images from their corresponding noisy image.

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...