I tried to used a pre-trained model that already was trained on three-channel color images, however, I am getting an error because of shape difference. Could someone let me know how can I tackle this issue?
One user had suggested using Tile
layer, but I could not find any relevant document/help for using this layer or any other solution. I really appreciate your help.
Asked
Active
Viewed 755 times
1

S.EB
- 1,966
- 4
- 29
- 54
-
You could send the same channel data to all three if you don't want to retrain the model. – nomem Apr 02 '17 at 08:45
-
Could you please explain in more detail. I am not expert in the area. – S.EB Apr 02 '17 at 11:49
-
2I am assuming you have grayscale image. You could convert it to rgb image by repeating grayscale values in the rgb channels. There is opencv function like `rgb = cv2.cvtColor(gray,cv2.COLOR_GRAY2RGB)` to do that too. Then you can use that image to your pretrained model. – nomem Apr 02 '17 at 12:07
-
@Inman: Do you know how this changes performance (e.g. accuracy of a classification network)? I have no idea if we speak about -5% on Top5 ImageNet accuracy or rather -30% – Martin Thoma Apr 03 '17 at 08:17
-
@MartinThoma You are right we have no idea how it will perform. That is why in his previous question I suggested him to retrain if he needs transfer learning to work. Another option could be recovering rgb image from grayscale using deep learning. I read a paper somewhere about this. But that is a long shot. – nomem Apr 03 '17 at 14:10
-
1@Inman: [Deep Colorization](https://arxiv.org/pdf/1605.00075.pdf) - I know this technique, but I didn't suggest it I don't think he would be able to do it. (But Deep Colorization vs Retraining with Grayscale would be an interesting comparison!) – Martin Thoma Apr 03 '17 at 14:15
-
1@MartinThoma Yes, I thought that too. Thanks for the link. It might be an interesting comparison. S.EB could shed some light on the performance for now. – nomem Apr 03 '17 at 16:22
-
@lnman Thanks for your suggestion, It worked for me – S.EB Apr 04 '17 at 15:42
1 Answers
2
There is not much information in caffe.proto
about tile layer. If you look at the code it just copies data tiles
times for each outer dimension. For your case it should be:
layer{
name: "tile"
type: "Tile"
bottom: "bottom-blob"
top: "top-blob"
tiling_param {
// axis is 1 by default
tiles: 3
}
}

nomem
- 1,568
- 4
- 17
- 33