Train the Network
Define the training function and update weights based on errors.
We'll cover the following
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 handson with 1200+ tech skills courses.