0

I am running fcn-alexnet for semantic segmentation, I downloaded the pretrained model. Since my data is single channel,it is showing an error:

 ERROR: Cannot copy param 0 weights from layer 'conv1'; shape mismatch. Source param shape is 96 3 11 11 (34848); target param shape is 96 1 11 11 (11616). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

Could someone please guide me? The shape is as follows:

Feature shape (1, 256, 256)
Label shape (1, 256, 256)
S.EB
  • 1,966
  • 4
  • 29
  • 54
  • 1
    you can't load a blob partially without changing caffe code. As the error already suggests you should rename the layer. and train. – nomem Mar 31 '17 at 14:40

1 Answers1

0

If you only needed to retrain the last layer, you could just rename it (see this answer: https://stackoverflow.com/a/39837047/2404152).

In your case, the problem is that 96x3x11x11 != 96x1x11x11. You're trying to apply a pretrained model that was intended for color images to a grayscale dataset (as you already discovered). The simplest fix is to just train on color images as well. One way to do this would be to add a Tile layer to copy the input three times.

Obviously, that wouldn't be very efficient. But that's the only way I can think of to use the pretrained model on grayscale data.

Community
  • 1
  • 1
Luke Yeager
  • 1,400
  • 1
  • 17
  • 30
  • ThanksHow can I apply tile layer? after data layer and bottom and top layer what should be? IS this correct? layers { name: "tl" type: "Tile" bottom: "data" top: "data" tiling_param { tile_dim: 3 } } – S.EB Mar 31 '17 at 17:48
  • I think that's about right. But you can't do it in-place since the shape changes. So call the output "data_tiled" or something like that. – Luke Yeager Apr 03 '17 at 16:06