You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that when using noise for the seed sometimes it fails with the message "function value changing less than tolX" and all I have to do is keep rerunning the same command until it runs - then all is fine.
Further more, I have determined that when this happens, the total loss between the first iteration and the second iteration is 0.
I added some logic to catch it
local function main(params)
local lastTotalLoss = 0.0 -- declare a variable to keep track of last iteration total loss
around line 299:
print(string.format(' loss from last iteration: %f', (lastTotalLoss - loss)))
if (lastTotalLoss - loss) == 0.0 then
print('********** 0 loss from last iteration **********')
-- need to reinitialize image with new noise seed
end
lastTotalLoss = loss
collectgarbage()
-- optim.lbfgs expects a vector for gradients
return loss, grad:view(grad:nElement())
I tried reinitializing the image like this, and it carried on where it would have stopped with the tolX error, but I get a blank image:
if (lastTotalLoss - loss) == 0.0 then
print('********** 0 loss from last iteration **********')
img = initImage(params)
y = net:forward(img)
dy = img.new(#y):zero()
loss = -1
end
lastTotalLoss = loss
I have never used torch before, so I feel a little lost still! Oh yeah, I put the image init stuff in a function so I could reuse it (above):
local function initImage(params)
-- Initialize the image
if params.seed >= 0 then
torch.manualSeed(params.seed)
end
local img = nil
if params.init == 'random' then
img = torch.randn(content_image:size()):float():mul(0.001)
elseif params.init == 'image' then
img = content_image_caffe:clone():float()
else
error('Invalid init type')
end
if params.gpu >= 0 then
img = img:cuda()
end
return img
end
local img = initImage(params)
I have noticed that when using noise for the seed sometimes it fails with the message "function value changing less than tolX" and all I have to do is keep rerunning the same command until it runs - then all is fine.
Further more, I have determined that when this happens, the total loss between the first iteration and the second iteration is 0.
I added some logic to catch it
around line 299:
I tried reinitializing the image like this, and it carried on where it would have stopped with the tolX error, but I get a blank image:
I have never used torch before, so I feel a little lost still! Oh yeah, I put the image init stuff in a function so I could reuse it (above):
The whole file is attached.
neural_style.lua.txt
The text was updated successfully, but these errors were encountered: