You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
This autograd tool for torch is wonderful! I like it a lot :)
I just have a small question. I found that the output of logSoftMax does not match the normal nn.logSoftMax when minibatch is applied (e.g., batch size >1). I think the problem is in util.logSumExp(), one shouldn't take max=torch.max(array). Instead, one should take the maximum of each row. Is it true? Are there any easy fix for that? (see below)
--Thanks!
function util.logSumExp(array)
local max = torch.max(array)
return torch.log(torch.sum(torch.exp(array-max))) + max
end
function util.logSoftMax(array)
return array - util.logSumExp(array)
end
The text was updated successfully, but these errors were encountered:
local function logSumExp(array)
local max = torch.max(array,2)
local c=torch.expand(max,array:size(1),array:size(2))
return torch.log(torch.sum(torch.exp(array-c),2)) +max
end
local function logSoftMax(array)
local rlt=logSumExp(array)
local c=torch.expand(rlt,array:size(1),array:size(2))
return array-c
end
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
This autograd tool for torch is wonderful! I like it a lot :)
I just have a small question. I found that the output of logSoftMax does not match the normal nn.logSoftMax when minibatch is applied (e.g., batch size >1). I think the problem is in util.logSumExp(), one shouldn't take max=torch.max(array). Instead, one should take the maximum of each row. Is it true? Are there any easy fix for that? (see below)
--Thanks!
function util.logSumExp(array)
local max = torch.max(array)
return torch.log(torch.sum(torch.exp(array-max))) + max
end
function util.logSoftMax(array)
return array - util.logSumExp(array)
end
The text was updated successfully, but these errors were encountered: