Skip to content

Commit

Permalink
Fix Siamese example (NVIDIA#1405)
Browse files Browse the repository at this point in the history
Broadcast -1 into all elements that equal 0 in original label.
  • Loading branch information
gheinrich authored and lukeyeager committed Jan 20, 2017
1 parent b2aed1a commit 42baca1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/siamese/mnist_siamese.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ return function(params)
function siameseLabelHook(input, dblabel)
-- cosine embedding criterion requires negative samples to be
-- assigned class -1
dblabel[torch.eq(dblabel,0)]=torch.eq(dblabel,0):fill(-1)
dblabel[torch.eq(dblabel,0)]=-1
return dblabel
end

Expand All @@ -71,4 +71,3 @@ return function(params)
labelHook = siameseLabelHook
}
end

0 comments on commit 42baca1

Please sign in to comment.