CS:4980:006 Deep Learning Assignment 1: Due 9/6/2018


We are studying a Python program for creating multi layer general neural networks: mlnn.py

Now it is time for us to read and understand the code and play with this program.

  1. Try to use the network architecture (2, 3, 4, 1) for the XOR example. Assuming the mini batch size is 1, please change the number of epochs and learning rate to make sure the final network produces the right answer for the XOR function. What are the values of weight matrices when you are successful? What is the minimal number of epoches and the corresponding learning rate you used for this success.

  2. The feedforward function computes the output of the network:
       def feedforward(self, a):
            for w, b in zip(self.weights, self.biases):
                a = self.activation(np.dot(a, w) + b)
            return a
    
    If the input S is a two dimensional numpy array such that each row of S is an input to the network, can we use feedforward(S) to compute all the outputs for the inputs in S? Please experiment this in Python and use the experimental result to explain why this can or cannot be done.

  3. For the XOR example, the expected output is defined by
               train_Y = np.array([0, 1, 1, 0])
    
    The shape of train_Y is (4,). If we reshape train_Y so that its shape becomes (4, 1), do we need to modify class Network so that it works on the new shape of train_Y? The new shape can cover the cases when there are more than one value in the output. Please experment this in Python and use the experimental result to explain why the code of class Network needs change or not.

  4. The majority function f(x, y, z) returns the majority value of the three boolean inputs. E.g., f(0, 1, 0) = 0 and f(1, 1, 0) = 1. Please create a file called majority.py, which uses mlnn.py to create a neural network with the architecture (3, 4, 1) and train it with the definition of the majority function using proper epoch number and learning rate (assuming the batch size is 1). Please submit your code and report the output of your network on the eight inputs of the majority function, the values of epoch numbers and learning rate.

Please submit everything required in the ICON dropbox for Assignment 1 before the deadline.

Thank you!