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

github.com/torch/optim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Seetapun <dseetapun@netflix.com>2016-04-12 21:32:15 +0300
committerDavid Seetapun <dseetapun@netflix.com>2016-04-12 21:32:15 +0300
commit477a5e7a60914bf14412b78cbbaa572418098d81 (patch)
tree7b6487b5dd7b95b94cbc641577fa67741339ef35 /nag.lua
parent5e11b9fc448f3612c93429dbd125c8aa0862d3d5 (diff)
remove copy of x to save memory
Diffstat (limited to 'nag.lua')
-rw-r--r--nag.lua10
1 files changed, 3 insertions, 7 deletions
diff --git a/nag.lua b/nag.lua
index 28c1326..fd4210d 100644
--- a/nag.lua
+++ b/nag.lua
@@ -42,11 +42,7 @@ function optim.nag(opfunc, x, config, state)
-- (1) evaluate f(x) and df/dx
-- first step in the direction of the momentum vector
- if not state.x_copy then
- state.x_copy = x:clone()
- else
- state.x_copy:resizeAs(x):copy(x)
- end
+
if state.dfdx then
x:add(mom, state.dfdx)
end
@@ -75,12 +71,12 @@ function optim.nag(opfunc, x, config, state)
state.deltaParameters = torch.Tensor():typeAs(x):resizeAs(dfdx)
end
state.deltaParameters:copy(lrs):cmul(dfdx)
+ x:add(-clr, state.deltaParameters)
state.dfdx:add(-clr, state.deltaParameters)
else
+ x:add(-clr, dfdx)
state.dfdx:add(-clr, dfdx)
end
- state.x_copy:add(state.dfdx)
- x:copy(state.x_copy)
-- (6) update evaluation counter
state.evalCounter = state.evalCounter + 1