safeSoftMax: Safe softmax function for computing weights
Description
Computes the weights \(w_i = \frac{e^{p_i}}{\sum_{j=1}^k e^{p_j}}\) from \(p_i\), \(i=1,\ldots,k\)
in a safe way to avoid overflows and to truncate automatically to zero low values of \(w_i\).
Usage
safeSoftMax(logs, expTrc = 30)
Value
A matrix of the size as logs containing the weights for each row.
Arguments
logs
matrix of logarithms where each row contains a set of \(p_1,\ldots,p_k\) to compute the weights from.
expTrc
truncation for exponential: exp(x) with x <= -expTrc is set to zero. Defaults to 30.