(nInstances,1) X];


funObj = @(W)SoftmaxLoss2(W,X,y,nClasses);
lambda0 = 1e-4;
lambda = lambda0*ones(nVars+1,nClasses-1);
lambda(1,:) = 0; <span class="comment">% Don't penalize biases</span>
fprintf(<span class="string">'Training multinomial logistic regression model...\n'</span>);
wSoftmax = minFunc(@penalizedL2,zeros((nVars+1)*(nClasses-1),1),options,funObj,lambda(:));
wSoftmax = reshape(wSoftmax,[nVars+1 nClasses-1]);
wSoftmax = [wSoftmax zeros(nVars+1,1)];
[junk yhat] = max(X*wSoftmax,[],2);
trainErr 