You can pass SGD a MethodCost with the method set to "cost_from_X". If the last layer of the MLP is Softmax, this will do what you want.