Softmax regression template (ex1c).