In softmax regression, the probability $P$ that an item is part of class $l$ is given by $$P(y^{(i)}=l | x^{(i)};\theta)=\frac{e^{\theta^Tx^{(i)}}}{\sum_{j=1}^k e^{\theta^Tx^{(j)}}}$$
I have implemented softmax regression, but seem to come into problems when the inner product $\theta^Tx^{(i)}$ is large (say, greater than 30-50,) in which case even a 64 bit float overflows. What's the recommended procedure to avoid this problem? I've been thinking about normalizing the input vector $x^{(i)}$ such that $x^{(i)\prime}=\frac{x^{(i)}}{|x^{(i)}|}$, but that could make prediction less dynamic.