Add cost monitor for validation and testing in sgd