Created by: emailweixu
This allows user to implement any type of cost by summing over the output of non-cost layers.
Change-Id: Ic55aaabbf0c1299e70b8e48a0effcc91f8f5bd29