Multi-class logistic regression
I found my own answer. I had defined 

w = theano.shared(rng.randn(feats), name="w")


and that was wrong.
The correct definition is:

w = theano.shared(rng.randn(feats, num_classes), name="w")


since the weights link 'feats'-number of input neuron to 'num_classes'-number of output neurons.