e-lab / ENet-training

351 stars 88 forks source link

Error when forwarding image with trained decoder #32

Closed Nestarneal closed 8 years ago

Nestarneal commented 8 years ago

Hi, I've trained an encoder and a decoder, and the training configuration as following:

Encoder:

th run.lua --dataset cv --datapath data/CamVid/ --model models/encoder.lua --save ../trained-model/encoder --cachepath ../trained-model/encoder/cache_dataset/ --devid 1 --nGPU 1 --imHeight 360 --imWidth 480 --labelHeight 45 --labelWidth 60

Decoder:

th run.lua --dataset cv --datapath data/CamVid/ --model models/decoder.lua --save ../trained-model/decoder --cachepath ../trained-model/decoder/cache_dataset/ --CNNEncoder ../trained-model/encoder/model-best.net --devid 1 --nGPU 1 --imHeight 360 --imWidth 480 --labelHeight 360 --labelWidth 480

I used following script to try to forward a single image in the CamVid dataset,

require "image" require "nn" require "cunn" require "cudnn"

torch.setdefaulttensortype('torch.FloatTensor')

-- Get arguments local opts = require "opts" opt = opts.parse(arg)

-- Path to decoder/model-best.net and a single image in CamVid dataset local model = opt.model local img = opt.image

-- Load model from file model = torch.load(model) print(model)

-- Load image from file img = image.load(img) img = img:cuda() input = {} input[0] = img print(input)

-- Forward the image and print out the result local output = model:forward(input) print(output)

, and I got the following error message:

error

My question is

  1. Is there any mistakes when training encoder or decorder? Why "print(model)" only show the part of the network? (I DO NOT modify any lua files)

  2. It seems the image is loaded succesfully, and I also create a 4-D tensor for the input. What's going wrong?

Many thanks.

codeAC29 commented 8 years ago

See if issue #3 helps you.

Nestarneal commented 8 years ago

Thank you!

I replace torch.save(filename, model:clearState():get(1)) with torch.save(filename, model:clearState()) when training decoder, and everything goes fine. (--nGPU is set 1)

Closing the issue.