Skip to content

Commit

Permalink
LookupTable:maxParamNorm
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-leonard committed Jul 22, 2015
1 parent 8d7e6c0 commit 29cd5a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions LookupTable.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local LookupTable, parent = nn.LookupTable, nn.Module

function LookupTable:maxParamNorm(maxOutNorm, maxInNorm)
maxOutNorm = self.maxOutNorm or maxOutNorm or self.maxInNorm or maxInNorm
if not (maxOutNorm or maxInNorm) then
return
end

if maxOutNorm and maxOutNorm > 0 then
-- cols feed into output neurons
self.weight:renorm(2, 2, maxOutNorm)
end
if maxInNorm and maxInNorm > 0 then
-- rows feed out from input neurons
self.weight:renorm(2, 1, maxInNorm)
end
end
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ torch.include('dpnn', 'Module.lua')
torch.include('dpnn', 'Container.lua')
torch.include('dpnn', 'Sequential.lua')
torch.include('dpnn', 'ParallelTable.lua')
torch.include('dpnn', 'LookupTable.lua')

-- extensions to make serialization more efficient
torch.include('dpnn', 'SpatialMaxPooling.lua')
Expand Down

0 comments on commit 29cd5a8

Please sign in to comment.