Train the Network

Define the training function and update weights based on errors.

Training function

Now, let’s tackle the more involved training task. There are two parts to this:

  • The first part is working out the output for a given training example. That is no different from what we just did with the query() function.

  • The second part is taking this calculated output, comparing it with the desired output, and using the difference to guide how the network weights are updated.

We’ve already done the first part, so let’s write that out:

Get hands-on with 1400+ tech skills courses.