Open halfAnEngineer opened 6 years ago
def log_sum_exp(x) x_max = x.data.max() return torch.log(torch.sum(torch.exp(x-x_max), 1, keepdim=True)) + x_max In this function ,if we remove x_max,the output of this function is just the same,so why should we use the x_max ?
For numerical stability. This is almost always done when computing the softmax function: https://stackoverflow.com/questions/42599498/numercially-stable-softmax
Thank you, got it.
def log_sum_exp(x)
x_max = x.data.max() return torch.log(torch.sum(torch.exp(x-x_max), 1, keepdim=True)) + x_max In this function ,if we remove x_max,the output of this function is just the same,so why should we use the x_max ?