implement output layer training