DrSleep / tensorflow-deeplab-resnet

DeepLab-ResNet rebuilt in TensorFlow
MIT License
1.25k stars 429 forks source link

Adding an additional classification layer #61

Closed arslan-chaudhry closed 7 years ago

arslan-chaudhry commented 7 years ago

Hi @DrSleep. I am trying to add a new classification layer in addition to segmentation layer already present in the repo. Right now, I am adding an average pooling layer after 'res5c_relu', followed by a classification layer (fc layer). Something like this:

(self.feed('res5c_relu')
     .avg_pool(3, 3, 1, 1, name='class_fc_pool'))

(self.feed('class_fc_pool')
     .fc(20, name='class_voc12_classification', relu=False))

I can train the model fine. But at inference time, .fc layer in kaffe gives me following error:

TypeError: unsupported operand type(s) for *=: 'int' and 'NoneType'

What is the correct way of using the 'fc' layer in such a scenario. During training, I am making sure that I don't restore the classification layer weights (since they won't be there in the init.ckpt file) and initialize them appropriately. I am also making sure that during snapshot creation I am storing all the global_variables.