Training and evaluating the network