Added code for training and computing the outputs of each node.