In: Computer Science
1) Code in python for solving the MNIST classification problem (for
full size of the training set
Classify two digits from MNIST dataset
2) Logistic regression (LR) with L1 regularization
where LR is differentiable, But L1 norm is not
• Use proximal gradient descent
• For L1 norm, that’s soft-thresholding
• Use tensorflow library
The MNIST dataset is an acronym that stands for the Modified National Institute of Standards and Technology dataset.
It is a dataset of 60,000 small square 28×28 pixel grayscale images of handwritten single digits between 0 and 9.
The task is to classify a given image of a handwritten digit into one of 10 classes representing integer values from 0 to 9, inclusively.
It is a widely used and deeply understood dataset and, for the most part, is “solved.” Top-performing models are deep learning convolutional neural networks that achieve a classification accuracy of above 99%, with an error rate between 0.4 %and 0.2% on the hold out test dataset.
The example below loads the MNIST dataset using the Keras API and creates a plot of the first nine images in the training dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# example of loading the mnist dataset from keras.datasets import mnist from matplotlib import pyplot # load dataset (trainX, trainy), (testX, testy) = mnist.load_data() # summarize loaded dataset print('Train: X=%s, y=%s' % (trainX.shape, trainy.shape)) print('Test: X=%s, y=%s' % (testX.shape, testy.shape)) # plot first few images for i in range(9): # define subplot pyplot.subplot(330 + 1 + i) # plot raw pixel data pyplot.imshow(trainX[i], cmap=pyplot.get_cmap('gray')) # show the figure pyplot.show() |