Initialize the Neural Network
Let's begin with the initialization of the neural network.
We'll cover the following
Create the basic structure of a neural network
We know we need to set the number of input, hidden, and output layer nodes. This defines the shape and size of the neural network. We’ll use parameters to set their values. This way, we retain the choice to create new neural networks of different sizes with ease.
There’s an important point here. Good programmers, computer scientists, and mathematicians try to create general rather than specific code whenever they can. It’s a good habit because it forces us to think about solving problems in a more widely applicable way. If we do this, then our solutions can be applied to different scenarios. This means our code will keep many useful options open and assumptions to a minimum, so the code can easily be used for different needs. We want the same class to be able to create a small neural network as well as a very large one. We’ll accomplish this by passing the desired size as parameters.
We also can’t forget about the learning rate. That’s a useful parameter to set when we create a new neural network. So, let’s see what the __init__()
function might look like:
Get hands-on with 1400+ tech skills courses.