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

Testing the network #3

Closed
syed-ahmed opened this issue Jun 30, 2016 · 22 comments
Closed

Testing the network #3

syed-ahmed opened this issue Jun 30, 2016 · 22 comments

Comments

@syed-ahmed
Copy link
Contributor

Hi I was able to successfully train the encoder and the decoder. I wanted to test the network with an image and am setting up a script in Lua. I am a little confused understanding the network as an end-to-end system. When I load the .net file from training session of the decoder, I see the following model:

nn.ConcatTable {
  input
    |`-> (1): cudnn.SpatialConvolution(3 -> 13, 3x3, 2,2, 1,1)
    |`-> (2): nn.SpatialMaxPooling(2x2, 2,2)
     ... -> output
}   

However, when I load the .net file from the training session of the encoder, I see the model is much bigger. Am I suppose to pass the test image through the encoder and then connect the output of the encoder to the decoder?

Following is a snippet of how I'm loading the .net files.

require 'nn'
require 'image'
require 'cunn'
require 'cudnn'

test_img = '/path/to/image/test.png'
network = '/path/to/train/trained_decoder/model-299.net'
net = torch.load(network,'b64')
@codeAC29
Copy link
Contributor

codeAC29 commented Jun 30, 2016

As an end-to-end system, the trained decoder in itself is sufficient, i.e. you do not need encoder while testing as model trained as decoder contains both encoder and decoder in it.

  1. The model which you have shown above is just the initial block of the whole network. There will be 20 blocks like that for decoder. net:get(1) will give you the output which you have shown.
  2. Instead of model-299.net, try to use model-best.net either for training encoder from decoder or for evaluating.

@syed-ahmed
Copy link
Contributor Author

Thank you for your reply! I am a beginner in torch fyi. I actually got that output when I just did a print(tostring(net)). I am thinking of resizing my test image to 256x256 and then normalizing using the mean and std values (I saw their print out at the start of the training session) and doing a net:forward in torch and mapping the pixels to the CamVid color values (I trained on CamVid). Do you think I'm on the right track?

@syed-ahmed
Copy link
Contributor Author

syed-ahmed commented Jun 30, 2016

@codeAC29 Here is a quick script that I am writing without normalization, just to see an output by forwarding through the network. My end goal is to get a segmented output of the input image. Could you give me some hints on what I might be doing wrong?

require 'nn'
require 'image'
require 'cunn'
require 'cudnn'
torch.setdefaulttensortype('torch.FloatTensor')

test_img = '/path/to/image/test.png'
network = '/path/to/train/trained_decoder/model-best.net'
net = torch.load(network,'b64')

im = image.load(test_img)
im2 = image.scale(im, 256, 256)
im2 = im2:cuda()
output = net:forward(im2)
output
Output:
{
  1 : CudaTensor - size: 13x128x128
  2 : CudaTensor - size: 3x128x128
}

When executing itorch.image(output[1]) I see thirteen gray scale images as suggested by the output above. Are these grayscale images the labelled segmentation but just encoded (I see there are 12 classes in the categories.txt and one image in those 13 images is fully gray)?

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 1, 2016

  1. I think the decoder models have not been correctly trained then. As I said, the output which you are telling is the output of the first layer. There are total 20 layers such layers. Make sure you did not modify decoder.lua.
  2. You can try normalizing but do not resize CamVid images to 256x256 since it will change the aspect ratio.
  3. Your script for viewing the output is correct.
    Btw you can directly print network and you don't need to convert it into string.

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 1, 2016

Below is a part of what I see when I try to see my trained decoder (Keep in mind that this decoder is actually encoder+decoder).
screen shot 2016-07-01 at 12 30 07 am

To see the architecture of your trained model, a simple way is to just go in torch th and type the following:

require 'cunn';
require 'cudnn';
model = torch.load('model-best.net')
model

@syed-ahmed
Copy link
Contributor Author

syed-ahmed commented Jul 1, 2016

Thank you so much for your replies. I have not modified the decoder.lua. I have started the training on the decoder again. Following is the starting of the training session of the decoder. Could you please verify if something looks odd? In particular the command I'm using to start the session. For the CNNEncoder I am giving model-best.net from the encoder training session.

ubuntu@ip-172-31-15-24:~/ENet-training/train$ th run.lua --dataset cv --datapath /home/ubuntu/SegNet-Tutorial/CamVid/
 --model models/decoder.lua --save /home/ubuntu/ENet-training/train/trained_decoder/ --imHeight 360 --imWidth 480 --l
abelHeight 360 --labelWidth 480 --cachepath /home/ubuntu/ENet-training/train/decoder_cache/ --CNNEncoder /home/ubuntu
/ENet-training/train/trained_encoder/model-best.net                                                                    
Folder created at /home/ubuntu/ENet-training/train/trained_decoder/
==> load modules
==> number of classes: 12, classes:     {
  1 : "Void"
  2 : "Sky"
  3 : "Building"
  4 : "Column-Pole"
  5 : "Road"
  6 : "Sidewalk"
  7 : "Tree"
  8 : "Sign-Symbol"
  9 : "Fence"
  10 : "Car"
  11 : "Pedestrian"
  12 : "Bicyclist"
}
Extracting file names from: /home/ubuntu/SegNet-Tutorial/CamVid//train.txt
==> Loading traning data
 [======================================= 366/366 ==================================>]  Tot: 33s962ms | Step: 93ms   
Extracting file names from: /home/ubuntu/SegNet-Tutorial/CamVid//test.txt

==> Loading testing data
 [======================================= 232/232 ==================================>]  Tot: 13s155ms | Step: 56ms   
==> saving data to cache: /home/ubuntu/ENet-training/train/decoder_cache/camVid/data.t7
==> verify statistics
training data, channel-1, mean: 0.41258420061683
training data, channel-1, standard deviation: 0.30702529663605
test data, channel-1, mean: 0.38033036508292
test data, channel-1, standard deviation: 0.29402536403664
training data, channel-2, mean: 0.42578845029602
training data, channel-2, standard deviation: 0.31155094980589
test data, channel-2, mean: 0.3908973772028
test data, channel-2, standard deviation: 0.2960684953069
training data, channel-3, mean: 0.43332112740325
training data, channel-3, standard deviation: 0.30714262731822
test data, channel-3, mean: 0.39693105922379
test data, channel-3, standard deviation: 0.29525659071874
saving opt as txt and t7
==> training!
==> define parameters
==> construct model
{
  1 : 
    {
      dH : 2
      dW : 2
      kW : 2
      gradInput : CudaTensor - empty
      kH : 2
      padW : 0
      indices : CudaTensor - empty
      _type : "torch.CudaTensor"
      train : false
      padH : 0
      ceil_mode : false
      iheight : 360
      output : CudaTensor - empty
      iwidth : 480
    }
  2 : 
    {
      dH : 2
      dW : 2
      kW : 2
      gradInput : CudaTensor - empty
      kH : 2
      padW : 0
      indices : CudaTensor - empty
      _type : "torch.CudaTensor"
      train : false
      padH : 0
      ceil_mode : false
      iheight : 180
      output : CudaTensor - empty
      iwidth : 240
    }
  3 : 
    {
      dH : 2
      dW : 2
      kW : 2
      gradInput : CudaTensor - empty
      kH : 2
      padW : 0
      indices : CudaTensor - empty
      _type : "torch.CudaTensor"
      train : false
      padH : 0
      ceil_mode : false
      iheight : 90
      output : CudaTensor - empty
      iwidth : 120
    }
}
defining loss function:
  }
  (30): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): nn.SpatialFullConvolution(4 -> 4, 3x3, 2,2, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> output]
        |      (1): nn.Identity
        |      (2): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (3): nn.SpatialBatchNormalization
        |      (4): nn.SpatialMaxUnpooling associated to nn.SpatialMaxPooling(2x2, 2,2)
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (31): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(16 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): cudnn.SpatialConvolution(4 -> 4, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (32): nn.SpatialFullConvolution(16 -> 12, 2x2, 2,2)
}
==> defining some tools
==> flattening model parameters
==> defining training procedure
confusion unlabel is not added
==> allocating minibatch memory
==> defining test procedure
confusion unlabel is not added
==> Training: epoch # 1 [batchSize = 2]
 [======================================= 235/366 ====>..............................]  ETA: 16s322ms | Step: 124ms 

@syed-ahmed
Copy link
Contributor Author

I just tried seeing the model in between the training session. Still getting the following:

th> network
nn.ConcatTable {
  input
    |`-> (1): cudnn.SpatialConvolution(3 -> 13, 3x3, 2,2, 1,1)
    |`-> (2): nn.SpatialMaxPooling(2x2, 2,2)
     ... -> output
}

I tried to look into the encoder network and it looks fine. Seems like for some reason this encoder part is not getting concatenated with the decoder. Could it be related to the CNNEncoder tag?

th> network
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) -> (26) -> (27) -> output]
  (1): nn.ConcatTable {
    input
      |`-> (1): cudnn.SpatialConvolution(3 -> 13, 3x3, 2,2, 1,1)
      |`-> (2): nn.SpatialMaxPooling(2x2, 2,2)
       ... -> output
  }
  (2): nn.JoinTable
  (3): nn.SpatialBatchNormalization
  (4): nn.PReLU
  (5): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(16 -> 16, 2x2, 2,2) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> output]
        |      (1): nn.Identity
        |      (2): nn.SpatialMaxPooling(2x2, 2,2)
        |      (3): nn.Padding
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (6): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (7): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (8): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (9): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (10): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 32, 2x2, 2,2) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> output]
        |      (1): nn.Identity
        |      (2): nn.SpatialMaxPooling(2x2, 2,2)
        |      (3): nn.Padding
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (11): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (12): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 2,2, 2,2)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (13): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 5x1, 1,1, 2,0) without bias
        |      (5): cudnn.SpatialConvolution(32 -> 32, 1x5, 1,1, 0,2)
        |      (6): nn.SpatialBatchNormalization
        |      (7): nn.PReLU
        |      (8): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (9): nn.SpatialBatchNormalization
        |      (10): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (14): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 4,4, 4,4)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (15): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (16): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 8,8, 8,8)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (17): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 5x1, 1,1, 2,0) without bias
        |      (5): cudnn.SpatialConvolution(32 -> 32, 1x5, 1,1, 0,2)
        |      (6): nn.SpatialBatchNormalization
        |      (7): nn.PReLU
        |      (8): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (9): nn.SpatialBatchNormalization
        |      (10): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (18): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 16,16, 16,16)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (19): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (20): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 2,2, 2,2)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (21): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 5x1, 1,1, 2,0) without bias
        |      (5): cudnn.SpatialConvolution(32 -> 32, 1x5, 1,1, 0,2)
        |      (6): nn.SpatialBatchNormalization
        |      (7): nn.PReLU
        |      (8): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (9): nn.SpatialBatchNormalization
        |      (10): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (22): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 4,4, 4,4)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (23): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (24): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 8,8, 8,8)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (25): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(32 -> 32, 5x1, 1,1, 2,0) without bias
        |      (5): cudnn.SpatialConvolution(32 -> 32, 1x5, 1,1, 0,2)
        |      (6): nn.SpatialBatchNormalization
        |      (7): nn.PReLU
        |      (8): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (9): nn.SpatialBatchNormalization
        |      (10): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (26): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(128 -> 32, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): nn.SpatialDilatedConvolution(32 -> 32, 3x3, 1,1, 16,16, 16,16)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(32 -> 128, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.100000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (27): cudnn.SpatialConvolution(128 -> 12, 1x1)
}

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 1, 2016

In your previous comment if you will see, the decoder is also displayed and there it is displayed correctly. It has 32 layers there.
I think you do not have the latest repo. Try to git pull and then run it again.

@syed-ahmed
Copy link
Contributor Author

syed-ahmed commented Jul 1, 2016

Hi @codeAC29. I did the git pull and trained the encoder and the decoder till max epoch 20. However, the trained decoder still shows:

th> network
nn.ConcatTable {
  input
    |`-> (1): cudnn.SpatialConvolution(3 -> 13, 3x3, 2,2, 1,1)
    |`-> (2): nn.SpatialMaxPooling(2x2, 2,2)
     ... -> output
}

I am training it on a g2.2x instance in amazon. I noted that the default --nGPU is 2. So I specified only 1 in this most recent training session. As you mentioned, I also verified that there were 32 layers at the start of the session this time. However, the end trained model doesn't give me the 32 layers. I did the following debugging:

  1. The typename of my trained encoder model returns nn.sequential.
  2. I noticed in the decoder.lua code that the loading of the CNNEncoder uses a check for nn.DataParallelTable and depending on it the model gets assigned model:get(1) and so on...

Do you think the gpu_list stuff is messing things up?

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 1, 2016

Are you using only one GPU and removed DataParallelTable? Try to print the model before this line. One thing you can try is to change this line with torch.save(filename, model:clearState()).

@syed-ahmed
Copy link
Contributor Author

Yes. I'm using only one GPU. I tried some approaches: 1) specified --nGPU as 1 without modifying any of the code. 2) hardcoded model = nn.DataParallelTable(1):add(model:cuda(), 1). 3) Removed DataParallelTable fully from encoder and decoder. I'll now try the things you mentioned.

@syed-ahmed
Copy link
Contributor Author

syed-ahmed commented Jul 1, 2016

Following is the output when I printed the model before the line you specified. I also replaced the torch.save line with your change. Now it seems like decoder is correctly getting the 32 layers. However, when I try to do a net:forward(image) on the decoder model, I get another error:

Error when doing a net:forward(image) through the model:
...e/ubuntu/torch/install/share/lua/5.1/nn/Container.lua:67: 
In 2 module of nn.Sequential:
...e/ubuntu/torch/install/share/lua/5.1/nn/JoinTable.lua:39: bad argument #1 to 'copy' (sizes do not match at /home/ubuntu/torch/extra/cutorch/lib/THC/generic/THCTensorCopy.cu:10)
stack traceback:
    [C]: in function 'copy'
    ...e/ubuntu/torch/install/share/lua/5.1/nn/JoinTable.lua:39: in function <...e/ubuntu/torch/install/share/lua/5.1/nn/JoinTable.lua:21>
    [C]: in function 'xpcall'
    ...e/ubuntu/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
    .../ubuntu/torch/install/share/lua/5.1/nn/Sequential.lua:44: in function 'forward'
    [string "output = net:forward(im2)..."]:1: in main chunk
    [C]: in function 'xpcall'
    /home/ubuntu/torch/install/share/lua/5.1/itorch/main.lua:209: in function </home/ubuntu/torch/install/share/lua/5.1/itorch/main.lua:173>
    /home/ubuntu/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
    ...ubuntu/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
    ...ubuntu/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
    ...ubuntu/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
    /home/ubuntu/torch/install/share/lua/5.1/itorch/main.lua:381: in main chunk
    [C]: in function 'require'
    (command line):1: in main chunk
    [C]: at 0x00406670
Output when changed to torch.save(filename, model:clearState()) with --nGPU 1
==> here is the model:
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) -> (26) -> (27) -> (28) -> (29) -> (30) -> (31) -> (32) -> output]
  (1): nn.ConcatTable {
    input
      |`-> (1): cudnn.SpatialConvolution(3 -> 13, 3x3, 2,2, 1,1)
      |`-> (2): nn.SpatialMaxPooling(2x2, 2,2)
       ... -> output
  }
  (2): nn.JoinTable
  (3): nn.SpatialBatchNormalization
  (4): nn.PReLU
  (5): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(16 -> 16, 2x2, 2,2) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> output]
        |      (1): nn.Identity
        |      (2): nn.SpatialMaxPooling(2x2, 2,2)
        |      (3): nn.Padding
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (6): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): nn.PReLU
        |      (4): cudnn.SpatialConvolution(16 -> 16, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): nn.PReLU
        |      (7): cudnn.SpatialConvolution(16 -> 64, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |      (9): nn.SpatialDropout(0.010000)
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): nn.PReLU
  }
  (7): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
  }
  (30): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): nn.SpatialFullConvolution(4 -> 4, 3x3, 2,2, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> output]
        |      (1): nn.Identity
        |      (2): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (3): nn.SpatialBatchNormalization
        |      (4): nn.SpatialMaxUnpooling associated to nn.SpatialMaxPooling(2x2, 2,2)
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
(31): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (30): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): nn.SpatialFullConvolution(4 -> 4, 3x3, 2,2, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> output]
        |      (1): nn.Identity
        |      (2): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (3): nn.SpatialBatchNormalization
        |      (4): nn.SpatialMaxUnpooling associated to nn.SpatialMaxPooling(2x2, 2,2)
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (30): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(64 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): nn.SpatialFullConvolution(4 -> 4, 3x3, 2,2, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> output]
        |      (1): nn.Identity
        |      (2): cudnn.SpatialConvolution(64 -> 16, 1x1) without bias
        |      (3): nn.SpatialBatchNormalization
        |      (4): nn.SpatialMaxUnpooling associated to nn.SpatialMaxPooling(2x2, 2,2)
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (31): nn.Sequential {
    [input -> (1) -> (2) -> (3) -> output]
    (1): nn.ConcatTable {
      input
        |`-> (1): nn.Sequential {
        |      [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> output]
        |      (1): cudnn.SpatialConvolution(16 -> 4, 1x1) without bias
        |      (2): nn.SpatialBatchNormalization
        |      (3): cudnn.ReLU
        |      (4): cudnn.SpatialConvolution(4 -> 4, 3x3, 1,1, 1,1)
        |      (5): nn.SpatialBatchNormalization
        |      (6): cudnn.ReLU
        |      (7): cudnn.SpatialConvolution(4 -> 16, 1x1) without bias
        |      (8): nn.SpatialBatchNormalization
        |    }
        |`-> (2): nn.Sequential {
        |      [input -> (1) -> output]
        |      (1): nn.Identity
        |    }
         ... -> output
    }
    (2): nn.CAddTable
    (3): cudnn.ReLU
  }
  (32): nn.SpatialFullConvolution(16 -> 12, 2x2, 2,2)
}
==> saving model to /home/ubuntu/ENet-training-2/ENet-training/train/trained_decoder/model-2.net

@syed-ahmed
Copy link
Contributor Author

syed-ahmed commented Jul 1, 2016

I have a hunch on that error. I am mostly taking inspiration from test.lua to run the model on a set of images. In test.lua at this line I see that the tensor has 4 elements consisting of batch size, channel, width and height, whereas here I'm just trying to pass channel, width and height only. Do you think that might be it?

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 1, 2016

Yes you need to pass a 4D tensor. So, just use a batch of 1 image.

@syed-ahmed
Copy link
Contributor Author

@codeAC29 Hi Abhishek, thank you again for your support. I am now able to forward through the model and get a 4D output tensor of 1x12x360x480. I looked through the values inside, for instance, output[1][1][2][3] gives 0.0053367093205452. I'm assuming these are log probablities (?). So to get pixel wise labelling like 1,2,3...instead of 0.005336, what kind of operation should I do (argmax?).

Also, could you explain why torch.save(filename, model:clearState()) solved my problem with having an incomplete model? Thank you.

@syed-ahmed
Copy link
Contributor Author

Here's how they look roughly when I exported them to pngs right after the forward pass.
2

@codeAC29
Copy link
Contributor

codeAC29 commented Jul 2, 2016

Your final output will have n number of channels, which is your number of classes. Out of these n channels suppose 2nd channel has maximum value for the first pixel then it means that pixel one belongs to class 2. One easy thing which I do is, squeeze the output (since first dimension is 1 which is number of batches) and then:

_, winners = output:max(1)

When you do model:get(1) then you get the first container of the model. Since we were using dataparalleltable, our first container was that, which we dont need during evaluation, thats why we used to get rid of it by :get(1). In your case you were not using it, therefore it took your first sequential container.

@syed-ahmed
Copy link
Contributor Author

Thank you! Closing the issue.

@ghost
Copy link

ghost commented Aug 2, 2016

Is there any available model out there to test ?

@culurciello
Copy link
Member

Here:
https://www.dropbox.com/sh/dywzk3gyb12hpe5/AAD5YkUa8XgMpHs2gCRgmCVCa

@ghost
Copy link

ghost commented Aug 2, 2016

Thank you @culurciello :)

@juntingzh
Copy link

@culurciello Is this model trained on training set only? Or the images in validation set are also used to finetune the model?

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

No branches or pull requests

4 participants