Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Linear.lua')
-rw-r--r--Linear.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/Linear.lua b/Linear.lua
index 953af78..cc6da4e 100644
--- a/Linear.lua
+++ b/Linear.lua
@@ -17,14 +17,16 @@ function Linear:reset(stdv)
else
stdv = 1./math.sqrt(self.weight:size(2))
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)
+ 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)
+ end
+ else
+ self.weight:uniform(-stdv, stdv)
+ self.bias:uniform(-stdv, stdv)
end
end