chuanli11 / CNNMRF

code for paper "Combining Markov Random Fields and Convolutional Neural Networks for Image Synthesis"
MIT License
865 stars 148 forks source link

error: attempt to index field 'nn' (a nil value) #12

Closed ghost closed 8 years ago

ghost commented 8 years ago

Ubuntu 14, bleeding edge torch install. I'm unsure what causes this error:

ggg@ggg-PC:~/000/CNNMRF$ qlua cnnmrf.lua -style_name ff2 -content_name ff1 -mode memory mkdir: cannot create directory ‘data/result/’: File exists mkdir: cannot create directory ‘data/result/trans/’: File exists mkdir: cannot create directory ‘data/result/trans/MRF/’: File exists mkdir: cannot create directory ‘data/result/trans/MRF/’: File exists [libprotobuf WARNING google/protobuf/io/coded_stream.cc:505] Reading dangerously large protocol message. If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h. [libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192 Successfully loaded data/models/VGG_ILSVRC_19_layers.caffemodel conv1_1: 64 3 3 3 conv1_2: 64 64 3 3 conv2_1: 128 64 3 3 conv2_2: 128 128 3 3 conv3_1: 256 128 3 3 conv3_2: 256 256 3 3 conv3_3: 256 256 3 3 conv3_4: 256 256 3 3 conv4_1: 512 256 3 3 conv4_2: 512 512 3 3 conv4_3: 512 512 3 3 conv4_4: 512 512 3 3 conv5_1: 512 512 3 3 conv5_2: 512 512 3 3 conv5_3: 512 512 3 3 conv5_4: 512 512 3 3 fc6: 1 1 25088 4096 fc7: 1 1 4096 4096 fc8: 1 1 4096 1000 cnn succesfully loaded nil nn.Sequential { input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> (15) -> (16) -> (17) -> (18) -> (19) -> (20) -> (21) -> (22) -> (23) -> (24) -> (25) -> output: nn.TVLoss (2): cudnn.SpatialConvolution(3 -> 64, 3x3, 1,1, 1,1) (3): cudnn.ReLU (4): cudnn.SpatialConvolution(64 -> 64, 3x3, 1,1, 1,1) (5): cudnn.ReLU (6): cudnn.SpatialMaxPooling(2,2,2,2) (7): cudnn.SpatialConvolution(64 -> 128, 3x3, 1,1, 1,1) (8): cudnn.ReLU (9): cudnn.SpatialConvolution(128 -> 128, 3x3, 1,1, 1,1) (10): cudnn.ReLU (11): cudnn.SpatialMaxPooling(2,2,2,2) (12): cudnn.SpatialConvolution(128 -> 256, 3x3, 1,1, 1,1) (13): cudnn.ReLU (14): nn.MRFMM (15): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1) (16): cudnn.ReLU (17): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1) (18): cudnn.ReLU (19): cudnn.SpatialConvolution(256 -> 256, 3x3, 1,1, 1,1) (20): cudnn.ReLU (21): cudnn.SpatialMaxPooling(2,2,2,2) (22): cudnn.SpatialConvolution(256 -> 512, 3x3, 1,1, 1,1) (23): cudnn.ReLU (24): nn.ContentLoss (25): nn.MRFMM } content_layers: 24 mrf_layers: 14 25 network has been built.


Synthesis started at resolution


Implementing mrf layers ... qlua: /home/ggg/000/CNNMRF/mylib/mrf.lua:152: attempt to index field 'nn' (a nil value) stack traceback: [C]: in function '__index' /home/ggg/000/CNNMRF/mylib/mrf.lua:152: in function 'updateGradInput' /home/ggg/torch/install/share/lua/5.1/nn/Module.lua:30: in function 'backward' /home/ggg/torch/install/share/lua/5.1/nn/Sequential.lua:84: in function 'backward' ./transfer_CNNMRF_wrapper.lua:336: in function 'opfunc' /home/ggg/000/CNNMRF/mylib/myoptimizer.lua:34: in function 'mylbfgs' ./transfer_CNNMRF_wrapper.lua:505: in function 'main' cnnmrf.lua:92: in main chunk ggg@ggg-PC:~/000/CNNMRF$

rayset commented 8 years ago

I got a similar error in cpu mode,but at another line. may I ask you the string you wrote in the terminal? what parameters did you use?

ghost commented 8 years ago

I got a similar error in cpu mode,but at another line. may I ask you the string you wrote in the terminal? what parameters did you use?

It's the very first line... And I assume it's the GPU by default, hopefully.

rayset commented 8 years ago

oh,sorry,my bad. I'll try the memory setting later to see if it stucks on line 152 for me too.

rayset commented 8 years ago

the fix proposed in the other issue open worked for me.

 I think replacing line 152 with the following should help you:

local subBias = self.bias:sub(i_start, i_end)

input.THNN.SpatialConvolutionMM_updateOutput(
  input:cdata(),
  self.output:cdata(),
  self.weight:cdata(),
  subBias:cdata(),
  self.finput:cdata(),
  self.fgradInput:cdata(),
  self.kW, self.kH,
  self.dW, self.dH,
  self.padW, self.padH
)
local temp = self.output

let me know if it works for you too.

I have no credit in that, but I hope it worked for you too.

ghost commented 8 years ago

Yes it worked. Thanks.