Exercise 8. Create a Layer object.

Layers

If you haven't read this article on the inner workings of fully-connected neural networks I recommend reading it now. Or you can watch the video below. They describe the type of layers we are going to be building for our framework.

Each layer in our neural network will have a number of input nodes, a number of output nodes, and weights connecting all the inputs to all the outputs. They will also have a nonlinear squashing function. We'll use the same one throughout for simplicity.

Coding challenge

  • In the nn_framework package, create a module called layer.py.
  • Create a class called Dense and initialize it with the number of inputs and outputs.
  • Initialize a 2D array of weights.
  • Import layer into run_framework.py. Use it to specify a one-layer model by making a one-element list of Dense layer objects. Pass this list of layers into the ANN as the model when initializing it.

My solution

Here is all the code we've written up to this point. As a warning, my code as a few extra lines that turned out to be unnecessary in the final project. You can safely ignore them.

Complete and Continue  
Discussion

5 comments