diff options
Diffstat (limited to 'SparseLinear.lua')
-rw-r--r-- | SparseLinear.lua | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/SparseLinear.lua b/SparseLinear.lua index ec8845e..f1a2be5 100644 --- a/SparseLinear.lua +++ b/SparseLinear.lua @@ -22,14 +22,16 @@ function SparseLinear:reset(stdv) else stdv = 1./math.sqrt(self.weight:size(1)) end - - -- we do this so the initialization is exactly - -- the same than in previous torch versions - for i=1,self.weight:size(1) do - self.weight:select(1, i):apply(function() - return torch.uniform(-stdv, stdv) - end) - self.bias[i] = torch.uniform(-stdv, stdv) * 0.000001 + if nn.oldSeed then + for i=1,self.weight:size(1) do + self.weight:select(1, i):apply(function() + return torch.uniform(-stdv, stdv) + end) + self.bias[i] = torch.uniform(-stdv, stdv) * 0.000001 + end + else + self.weight:uniform(-stdv, stdv) + self.bias:uniform(-stdv, stdv):mul(0.000001) end end |