Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when forwarding image with trained decoder #32

Closed
Nestarneal opened this issue Nov 17, 2016 · 2 comments · May be fixed by #39
Closed

Error when forwarding image with trained decoder #32

Nestarneal opened this issue Nov 17, 2016 · 2 comments · May be fixed by #39

Comments

@Nestarneal
Copy link

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
Copy link
Contributor

See if issue #3 helps you.

@Nestarneal
Copy link
Author

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.

@ghost ghost mentioned this issue Dec 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants