follow Stanford's deep learning web to finish the exercise