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

github.com/clementfarabet/lua---nnx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Farabet <clement.farabet@gmail.com>2011-10-31 23:18:16 +0400
committerClement Farabet <clement.farabet@gmail.com>2011-10-31 23:26:49 +0400
commit3d2c1e5d0a11d1f590fb5ca1daf2fcd15d0b5d0b (patch)
tree7359d89628eefb37989dd17cb5b5dc327f17c999
parent7a392bb6812672859a484220e753366baf1bff71 (diff)
Correct? lbfgs eval
-rw-r--r--LBFGSOptimization.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/LBFGSOptimization.lua b/LBFGSOptimization.lua
index 30321eb..fce9ba5 100644
--- a/LBFGSOptimization.lua
+++ b/LBFGSOptimization.lua
@@ -37,12 +37,16 @@ end
function LBFGS:optimize()
-- callback for lBFGS
- lbfgs.evaluate = self.evaluate
-
- -- allreduce sync
- if self.allreduce then
- allreduce.accumulate(self.parameters)
- end
+ lbfgs.evaluate = function()
+ local loss = self.evaluate()
+ if self.allreduce then
+ local losst = torch.Tensor(1):fill(loss)
+ allreduce.accumulate(losst)
+ allreduce.accumulate(self.gradParameters)
+ loss = losst[1]
+ end
+ return loss
+ end
-- the magic function: will update the parameter vector according to the l-BFGS method
self.output = lbfgs.run()