Project- Predicting Noisy Images using KNN Classifier

4 / 10

Predicting Noisy Images - Load the Data

In this step we will load the dataset, and then store it into train and test sets. The dataset consists of 4 files:

train-images-idx3-ubyte.gz
train-labels-idx1-ubyte.gz
t10k-images-idx3-ubyte.gz
t10k-labels-idx1-ubyte.gz

These files are located at the following path:

/cxldata/datasets/project/mnist/

Finally, we will store them in 4 variables:

X_train, y_train, X_test, y_test

INSTRUCTIONS
  1. Provide the path to the files:

    filePath_train_set = '/cxldata/datasets/project/mnist/train-images-idx3-ubyte.gz'
    filePath_train_label = '<< your code goes here >>/train-labels-idx1-ubyte.gz'
    filePath_test_set = '<< your code goes here >>/t10k-images-idx3-ubyte.gz'
    filePath_test_label = '/cxldata/datasets/project/mnist/t10k-labels-idx1-ubyte.gz'
    
  2. Open the Gzip files:

    with gzip.open(filePath_train_label, 'rb') as trainLbpath:
         trainLabel = np.frombuffer(trainLbpath.read(), dtype=np.uint8,
                                   offset=8)
    with gzip.open(filePath_train_set, 'rb') as trainSetpath:
         trainSet = np.frombuffer(trainSetpath.read(), dtype=np.uint8,
                                   offset=16).reshape(len(trainLabel), 784)
    
    with gzip.open(filePath_test_label, 'rb') as testLbpath:
         testLabel = np.frombuffer(testLbpath.read(), dtype=np.uint8,
                                   offset=8)
    
    with gzip.open(filePath_test_set, 'rb') as testSetpath:
         testSet = np.frombuffer(testSetpath.read(), dtype=np.uint8,
                                   offset=16).reshape(len(testLabel), 784)
    
  3. Store the data into the 4 variables:

    X_train, << your code goes here >>, y_train, y_test = trainSet, testSet, trainLabel, << your code goes here >>
    
See Answer

No hints are availble for this assesment


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

Loading comments...