CSci 4511 - Homework 5

Optional Homework 5 -- due Thursday April 25

This homework will be graded out of 100 points. It will count 5% of the grade. It is optional, the credit received will be considered extra credit.
  1. [30 points] Consider the following variation to the block stacking domain; blocks are arranged on a table in N^2 locations corresponding to the cells of a N x N grid. At most one block can be located in any given location and no more than H blocks can be stacked.
    1. Define action schemas for moving blocks between locations, between blocks, and between locations and blocks. Define the predicates you use and make sure the notation you use for writing the schemas is clearly defined.
    2. Assume the initial state and goal state are completely specified (i.e. you know where each block is), and assume the number of blocks is less or equal to N^2. You do not need to answer this part. These are the assumptions you should make, which might be important for your algorithm
    3. Propose a trivial algorithm (not a planning algorithm) for solving any problem in this domain.
    4. Is your algorithm guaranteed to find an optimal solution in terms of number of steps?
    5. Discuss briefly the advantages, if any, of using a planning system compared to your solution.
  2. [20 points]
    1. How does the ``closed world assumption'' affect planning? Be precise.
    2. Why preconditions in action schemas are conjunctions and not disjunctions?
    3. Why variables that appear in the effects of an action schema have to be in the preconditions?
    4. Why an initial state for planning needs to have ground atoms (no variables)?
  3. [20 points] This question is about a feed forward neural network with no hidden nodes.
    Use the code posted at https://iamtrask.github.io/2015/07/12/basic-python-network/ The code is very simple and clean. The article describes it in detail.
    1. [5 points] Download the code NN1.py and run it. The program will print something like:
      
      Output After Training:
      [[ 0.03178421]
       [ 0.02576499]
       [ 0.97906682]
       [ 0.97414645]]
      
      which shows output values for each input close to y.
    2. [5 points] To see what happened, print the final weights that the network has learned.
    3. [10 points] Given new input data, use the learned weigths to classify the new data. Try as new input [1,2,1], [0,4,1], [5,2,1], and [-2,4,1]. To see the output of the network when new data are presented you need to multiply the data by the weigths in the network and pass the result through the nonlin function, as in k0=nonlin(np.array([1,2,1]).dot(syn0)) You can classify the new data one by one or all together.
    4. [not required] If you are curious, you could plot the error as it changes over the training. This requires keeping track of the error during the training loop.
      To plot in python, do
      import matplotlib.pyplot as plt
      
      and use the functions plt.plot and plt.show to do the plotting.
  4. [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. [5 points] Download the code NN2.py and execute it. The program has data to compute exclusive OR. It will print (I added to the print statement the epoch) something like:
      
      epoch 0 Error: 0.496410031903
      epoch 10000 Error: 0.00858452565325
      epoch 20000 Error: 0.00578945986251
      epoch 30000 Error: 0.00462917677677
      epoch 40000 Error: 0.00395876528027
      epoch 50000 Error: 0.00351012256786
      Output After Training: 
      [[ 0.00260572]
       [ 0.99672209]
       [ 0.99701711]
       [ 0.00386759]]
      
      which showns the network on the given inputs produces output values close to y.
    2. [15 points] 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 epoch to reduce the error? Print the output after training and the weigths in both layers after training.
    3. [10 points] Change the input data set and the corresponding output as follows:
      X= np.array([[0,0,1],[0,1,1],[1,0,1],[1,1,1],[0,0,0],[1,1,0],[0,1,0],[1,0,0]])
      Y= np.array([[0],[1],[1],[0],[0],[1],[1],[0]])
      
      and run the program again with 4 hidden nodes as in the original program. Print the output after training.
    4. [10 points] Try these different input data:
      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 a network with 2 hidden nodes. Run the program for 10,000 epochs and print the output after training and the weigths in both layers after training.
    For the programming questions, you need to submit the output of your programs with some prints/comments to show what each part is. Submit the NN1.py and NN2.py only if you change them more than just changing the number of nodes.
    Copyright: © 2019 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.