Exercise:Vectorization

From Ufldl

Revision as of 18:06, 28 April 2011 by Maiyifan (Talk | contribs)
Jump to: navigation, search

Contents

Vectorization

In the previous problem set, we implemented a sparse autoencoder for patches taken from natural images. In this problem set, you will adapt your sparse autoencoder to work on images of handwritten digits.

Support Code/Data

The following additional files are required for this exercise:

Step 1: Vectorize your Sparse Autoencoder Implementation

Using the suggestions from Vectorization and Neural Network Vectorization, vectorize your implementation of sparseAutoencoderCost.m. In our implementation, we were able to remove all for-loops with the use of matrix operations, repmat (and/or bsxfun). A vectorized version of our code ran in under one minute on a fast computer (for learning 25 features from 1000 8x8 image patches).

(Note that you do not need to vectorize the code in the other files.)

Step 2: Learn features for handwritten digits

Now that you have vectorized the code, it is easy to learn larger sets of features on medium sized images. In this part of the exercise, you will use your sparse autoencoder to learn features for handwritten digits from the MNIST dataset.

The MNIST data is available at [1]. Download the file train-images-idx3-ubyte.gz and decompress it. After obtaining the source images, we have provided functions help you load them up as Matlab matrices.

The following set of parameters worked well for us to learn good features on the MNIST dataset:

visibleSize = 28*28
sparsityParam = 0.1
lambda = 3e-3
beta = 3

After 200 iterations of updates using minFunc, your autoencoder should have learned features that resemble pen strokes. Our implementation takes around 25-30 minutes on a fast machine. Visualized, the features should look like in the following image:

MNIST-false-0.1-3e-3-3-linear.png

If your parameters are improperly tuned, or if your implementation of the autoencoder is buggy, you may get one of the following images instead:

MNIST-false-bad-1.pngMNIST-false-bad-2.png

If your image looks like one of the above images, check your code and parameters again. Learning these features are a prelude to the later exercises, where we shall see how they will be useful for classification.


Personal tools