CSci 4511 - Homework 5

Homework 5 -- due Wednesday April 22

This homework will be graded out of 100 points. It will count 5% of the grade.

1 [35 ponts]. Classification with one hidden layer neural network

For this part of the assignment you will use jupyter to complete a program in python to do classification with one hidden layer neural net.

Copy the file homework_week12_neural_network.zip, unzip it, and follow the instructions.

2 [30 points]. Feed forward neural network with hidden nodes

For this part we will start from the code posted at https://iamtrask.github.io/2015/07/12/basic-python-network/ under 3 layer neural network.
  1. Download the code NN2.py and execute it. The file contains the input, which has 4 training examples:
    
    # input data
    X = np.array([[0,0,1], [0,1,1], [1,0,1], [1,1,1]])
    	
    and the desired output:
    
    # output data
    y = np.array([[0], [1], [1], [0]])
    	
    Each input is a point in 2D. The output is the classification result we want for each point, either 0 or 1. This question uses input data for the exclusive OR.
  2. Change the number of hidden nodes from 4 to 3. Does the network converge? Does it take more epoch to converge? Do you need more epochs to reduce the error?

3 [35 points]. One more dataset

This question uses a set of points in 2d as dataset.
  1. Use the program you have just used, but change the values for X and y in the program. Use the following data:
    
    # 2d points, 2 classes, the last value in each row of X is the bias
    X = np.array([[1,1,1],[1,2,1],[2,2,1],[2,3,1],[2,1,1],[3,2,1],[4,1,1],[4,2,1]])
    y = np.array([[0],[0],[0],[0],[1],[1],[1],[1]])
    
    and run the program. Check that the program converges.
  2. Use the network you have just trained to classify new data. To do it, take from the program the part of the code that does the feed forward and use it to classify new data. For the new data use:
    
    newX=np.array([[3,3,1],[4,3,1]])
    
    and show the output. What does the output tell you? How are the new points classified?

Extra credit: 20 points

  1. Plot the data set X from the last problem using a different color depending on the class. Plot also the new points with the correct color after they have been classified.
  2. Train a network with 4 hidden nodes, using the following points:
    
    X = np.array([[1,1,1],[1,2,1],[2,2,1],[2,3,1],[2,1,1],[3,2,1],[3,4,1],[2,4,1],[1,3,1]])
    y = np.array([[0],[0],[0],[0],[1],[1],[1],[1],[1]])
    
    Does the network converge? if you plot the points, are the classes linearly separable or not?
Copyright: © 2020 by the Regents of the University of Minnesota
Department of Computer Science and Engineering. All rights reserved.
Comments to: Maria Gini
Changes and corrections are in red.