Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to make compatible with MarginRankingCriterion #108

Merged
merged 3 commits into from Apr 28, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion ModuleFromCriterion.lua
Expand Up @@ -24,7 +24,17 @@ end
function ModuleFromCriterion:updateGradInput(input, gradOutput)
local prediction, target = unpack(input)
local gradPrediction = self.criterion:updateGradInput(prediction, target)
self.gradInput[1]:resizeAs(gradPrediction):copy(gradPrediction):mul(gradOutput[1])
if type(gradPrediction) == 'table' then
if type(self.gradInput[1]) ~= 'table' then
self.gradInput[1] = gradPrediction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, aren't you forgetting to multiply by gradOutput[1]?

Copy link
Contributor Author

@abhitopia abhitopia Apr 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soumith - Thanks for pointing out. Fixed it now. Hopefully this time around, it is correct.

else
for i=1, #gradPrediction do
self.gradInput[1][i]:resizeAs(gradPrediction[i]):copy(gradPrediction[i]):mul(gradOutput[1])
end
end
else
self.gradInput[1]:resizeAs(gradPrediction):copy(gradPrediction):mul(gradOutput[1])
end
self.gradInput[2]:resizeAs(target):zero()
return self.gradInput
end