COMP 200: Elements of Computer Science
Spring 2013

Creating a Neural Net

We are giving you code where numerous definitions have been left out. We will first discuss the overall structure of the code and data structure. You'll then have class time to complete the code.

Problem Decomposition

This code is more complex than anything you've previously seen in this course. It involves several classes:

These definitions are interrelated. An ANN has multiple Layers. Each Layer has multiple ANNNodes. Each WeightedEdge has two endpoints, each of which is an ANNNode from adjacent Layers.

As always, the way to deal with complexity is to break it down into smaller chunks. We have already done this problem decomposition for you by outlining what the classes and methods will be. If you focus on each individual method and what it needs to do, completing the code shouldn't be too difficult. In our solution, each of the omitted pieces is only a few lines of code. However, a common difficulty is that students get distracted by the complexity of the big picture.

Creating vs. Using Structure

As we have seen before, there are class methods for creating the data structure. But, in addition, this example also embeds most of the code for using the structure into the classes. So, for example, once you create a neural net ann, you then use ann.train() to train it. Anthropomorphizing the code, you think of handing the training data to the neural net, and asking it to train itself. Similarly, ann.draw() asks the neural net to draw itself.

Another new, but simple, idea that is used by this code is delegation. In everyday speaking, you delegate a job by asking someone else to do it for you. In code, it is the same idea. As an example, since a neural net consists of layers of nodes, ann.draw() calls each Layer's draw() method, which in turn calls each ANNNode's draw() method. Thus, a neural net draws itself by asking its components to each draw themselves.

Your task will be to complete methods that create the neural net structure. All of the methods which then use this structure, either for learning or for drawing, have been fully provided. We have provided the more difficult and mathematical pieces.

Note that some methods have been marked as to be completed in class. We will give you completed versions of these after a couple classes. Other methods have been marked as part of the next assignment. During class, we won't give you the full solution to these.

Testing

An OwlTest suite is not yet ready.

Testing your own code will be somewhat challenging. We have provided one test in the code, but it is dependent on completing everything. Using the drawing routines can help, but they also are only fully functional when all of the code is completed.