Support
Quality
Security
License
Reuse
Coming Soon for all Libraries!
Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
http://torch.ch
Attempt to call local 'callback' (a nil value) error while trying to train SeGAN model
netG:apply(weights_init)
local function weights_init(m)
local name = torch.type(m)
if name:find('Convolution') then
m.weight:normal(0.0, 0.02)
m.bias:fill(0)
elseif name:find('BatchNormalization') then
if m.weight then m.weight:normal(1.0, 0.02) end
if m.bias then m.bias:fill(0) end
end
end
-----------------------
netG:apply(weights_init)
local function weights_init(m)
local name = torch.type(m)
if name:find('Convolution') then
m.weight:normal(0.0, 0.02)
m.bias:fill(0)
elseif name:find('BatchNormalization') then
if m.weight then m.weight:normal(1.0, 0.02) end
if m.bias then m.bias:fill(0) end
end
end
QUESTION
Attempt to call local 'callback' (a nil value) error while trying to train SeGAN model
Asked 2021-Jan-06 at 11:11I am trying to implement the "SeGAN: Segmenting and Generating the invisible" paper on ubuntu 18.04 with Geforce RTX 2060. I have installed the Driver, CUDA, cuDNN, Torch7 and dependencies and downloaded and extracted the dataset and weights folders and made a link to them. I tried to train the model with this line of code:
th main.lua -baseLR 1e-3 -end2end -istrain "train"
But I got this error:
define model netG...
/home/darya/distro/install/bin/luajit: /home/darya/distro/install/share/lua/5.1/nn/Module.lua:352: attempt to call local 'callback' (a nil value)
stack traceback:
/home/darya/distro/install/share/lua/5.1/nn/Module.lua:352: in function 'apply'
/home/darya/SeGAN/networks/End2EndNetwork.lua:81: in function 'defineG'
/home/darya/SeGAN/networks/End2EndNetwork.lua:130: in function 'init_networks'
/home/darya/SeGAN/networks/End2EndNetwork.lua:343: in main chunk
[C]: in function 'dofile'
main.lua:265: in main chunk
[C]: in function 'dofile'
...rya/distro/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x55e8fde0f570
I don't know what am I doing wrong and since I don't have much experience I am confused. Can someone help me to fix this problem, please? I appreciate it so much.
github repository for SeGAN segmenting and generating the invisible
ANSWER
Answered 2021-Jan-06 at 11:11From the linked GitHub repo:
netG:apply(weights_init)
weights_init
is supposed to be a function value but is nil.
Which in Module:apply
causes callback(self)
in Torch nn's Module.lua Line352 to fail.
Looks like someone has to implement that function.
Like in https://github.com/phillipi/pix2pix/blob/89ff2a81ce441fbe1f1b13eca463b87f1e539df8/train.lua, which https://github.com/ehsanik/SeGAN/blob/d29e0a5ac08f093b87dc82af3707d50107900d04/networks/End2EndNetwork.lua#L73 refers to.
where
local function weights_init(m)
local name = torch.type(m)
if name:find('Convolution') then
m.weight:normal(0.0, 0.02)
m.bias:fill(0)
elseif name:find('BatchNormalization') then
if m.weight then m.weight:normal(1.0, 0.02) end
if m.bias then m.bias:fill(0) end
end
end
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit