Description
Q1. Rosenbrock’s Valley Problem) Consider the Rosenbrock’s Valley function:
which has a global minimum at (x,y) = (1,1) where f(x,y) = 0. Now suppose the starting point is randomly initialized in the open interval (0, 0.5) for x and y, find the global minimum using:
a). Steepest (Gradient) descent method
w(k1) w(k)g(k)
with learning rate η = 0.001. Record the number of iterations when f(x,y) converges to (or very close to) 0 and plot out the trajectory of (x,y) in the 2-dimensional space. Also plot out the function value as it approaches the global minimum. What would happen if a larger learning rate, say η = 0.2, is used?
()
b). Newton’s method (as discussed on page 13 in the slides of lecture Four)
w(n)H1(n)g(n)
Record the number of iterations when f(x,y) converges to (or very close to) 0 and plot out the trajectory of (x,y) in the 2-dimensional space. Also plot out the function value as it approaches the global minimum.
()
Q2. Function Approximation ()
Consider using MLP to approximate the following function:
y1.2sin(x)cos(2.4x) , for x [ 1,1].
The training set is generated by dividing the domain [-1, 1] using a uniform step length 0.05, while the test set is constructed by dividing the domain [-1, 1] using a uniform step length 0.01. You may use the MATLAB neural network toolbox to implement a MLP (see the Appendix for guidance) and do the following experiments:
a). Use the sequential mode with BP algorithm and experiment with the following different structures of the MLP: 1-n-1 (where n = 1,2,…,10, 20, 50). For each architecture plot out the outputs of the MLP for the test samples after training and compare them to the desired outputs. Try to determine whether it is under-fitting, proper fitting or over-fitting. Identify the minimal number of hidden neurons from the experiments, and check if the result is consistent with the guideline given in the lecture slides. Compute the outputs of the MLP when x=-3 and +3, and see if the MLP can make reasonable predictions outside of the domain of the input limited by the training set.
() b). Use the batch mode with trainlm algorithm to repeat the above procedure.
()
c). Use the batch mode with trainbr algorithm to repeat the above procedure.
()
Q3. Scene Classification ()
Multi-layer perceptron (MLP) can be used to solve real-world pattern recognition problems. In this assignment, MLP will be designed to handle a binary classification task, i.e. nature scenes vs. man-made scenes. Specifically, students are divided into 4 groups based on matric numbers and each group is assigned with different dataset as illustrated in the following Table.
| Group ID | Nature Scenes [1] | Man-Made Scenes [0] |
| 1 |
Open Country |
Highway |
| 2 |
Mountain |
Street |
| 3 |
Coast |
Inside City |
| 4 |
Forest |
Tall Building |
You may download the zipped dataset (e.g. group_1.zip) from LumiNUS. After unzipping, you will find two folders: train and val. The training set consists of around 500 images and validation set consists of around 165 images. Filename of each image follows the format of “imageID_label_category.jpg” (e.g. 0001_0_highway.jpg), where ‘label’ is either 1 or 0 indicating the image captures a nature scene or man-made scene; ‘category’ represents the human-readable class name of this image.
In order to find your group, you need to calculate “mod(LWD, 4) + 1” where LWD is the last two digits of your matric number, e.g. A1234567X is assigned to group mod(67, 4) + 1 = 4 (Forest vs. Tall Building).
Please specify the group ID that has been assigned to you! Take note that if you have selected wrongly, there will be some mark deduction!
All the images are provided in grayscale format with size 256*256. You can use I = imread(filename) to read these image files, where filename specifies the path to an image (you may use function dir() to get the filenames of images inside a folder for code efficiency). The returned value I is an array (256-by-256 in this assignment) containing the image data. For example,
I = imread(‘group_1/train/0001_0_highway.jpg’);
will read image ‘0001_0_highway.jpg’ from the training set into MATLAB workspace. Then, you could display this image using: imshow(I, []);
In order to efficiently process all the image data, you may need to convert the matrix form data I into a vector by:
V = I(:);
and the resulting V is a column vector whose elements are taken column-wisely from I. You could group all the training images together using train_images = [V1, V2, …] and all the test images together following the same way. In the next, these matrixes (of size (256*256-by-image_number)) are used as input to the networks.
The label information is stored in the filename of each image and can be extracted by: tmp = strsplit(‘0001_0_highway.jpg’, {‘_’, ‘.’});
L(i)= str2num(tmp{2});
where L is an array (of size (1-by-image_number)) with each element holding the ground-truth label of corresponding image.
You are required to complete the following tasks:
- a) Apply Rosenblatt’s perceptron (single layer perceptron) to the dataset of your assigned group. After the training procedure, calculate the classification accuracy for both the training set and validation set, and evaluate the performance of the network.
(b) The original input dimension is 65536 (256*256), which may be redundant and contain space for reduction. Try to naively downsample the images into 128*128, 64*64, 32*32, or apply a more sophisticated technique like PCA to these images. Then, retrain the perceptron in a) with these dimensionally reduced images and compare their performance. (you may use imresize() and processpca() or pca() in this task)
) c) Apply MLP to the dataset of your assigned group using batch mode training. After the training procedure, calculate the classification accuracy for both the training set and validation set, and evaluate the performance of the network.
() d) Please determine whether your trained MLP in c) is overfitting. If so, please specify when (i.e. after which training epoch) it becomes overfitting. Try weights regularization and observe if it helps. (you may set the regularization strength by ‘performParam.regularization’)
() e)Apply MLP to the dataset of your assigned group using sequential mode training. After the training procedure, calculate the classification accuracy for both training set and validation set, and evaluate the performance of the network. Compare the result to part c), and make your recommendation on the two approaches.
) f) Try to propose a scheme that you believe could help to improve the performance of your MLP and please explain the reason briefly.



