fix antithetic ARS
This commit is contained in:
parent
ccce6a2d55
commit
74eb2bfbef
1 changed files with 7 additions and 8 deletions
15
ars.lua
15
ars.lua
|
@ -105,12 +105,13 @@ function Ars:ask(graycode)
|
||||||
local asking = zeros(self.dims)
|
local asking = zeros(self.dims)
|
||||||
local noisy = zeros(self.dims)
|
local noisy = zeros(self.dims)
|
||||||
asked[i] = asking
|
asked[i] = asking
|
||||||
|
noise[i] = noisy
|
||||||
|
|
||||||
if self.antithetic and i % 2 == 0 then
|
if self.antithetic and i % 2 == 0 then
|
||||||
for j, v in ipairs(self._params) do
|
local old_noisy = noise[i - 1]
|
||||||
asking[i] = v - noisy[j]
|
for j, v in ipairs(old_noisy) do
|
||||||
|
noisy[j] = -v
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
if graycode ~= nil then
|
if graycode ~= nil then
|
||||||
for j = 1, self.dims do
|
for j = 1, self.dims do
|
||||||
|
@ -124,13 +125,11 @@ function Ars:ask(graycode)
|
||||||
noisy[j] = self.sigma * nn.normal()
|
noisy[j] = self.sigma * nn.normal()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for j, v in ipairs(self._params) do
|
|
||||||
asking[j] = v + noisy[j]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
noise[i] = noisy
|
for j, v in ipairs(self._params) do
|
||||||
|
asking[j] = v + noisy[j]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.noise = noise
|
self.noise = noise
|
||||||
|
|
Loading…
Add table
Reference in a new issue