0
votes

I am solving a detection problem using ConvNet. However in my case the labels are matrix of dimension [3 x 5] for each image. I use Caffe for this work. I read the images using the Datalayer while I read the labels using HDF5Layer.

The HDF5Layer reads the [3x5] label matrix as [1x15] dimensional vector. So I used Reshape Layer with reshape the vector into matrix before computing the L2-loss. However I realized that the reshape layer formats the data in H x W while my label matrix is [W x H] i.e., [w=3, h=5] hence the reshape is incorrect. I wonder is there a way to reshape the [1x15] label vector in right order i.e., [3x5] and not [5x3]

Another way I thought I can work around is by flatten the output form Convolutional layer into [1 x 15] and then compute the loss using my [1 x 15] label.

I am showing the problem using Figures for better understanding because of my poor English.

Eample of my input matrix label (Note the images are just enlarged for illustration) Input Matrix Lab

Result of Caffe Reshape Layer

enter image description here

Any suggestion if I am doing it right?

1

1 Answers

1
votes

Either way of computing the loss is just fine. In fact, computing in the 1x15 shape will save you the time of converting. The loss computation is still pixel-by pixel; the logical organization doesn't matter.

Using the same idea, it doesn't really matter whether you compute 3x5 or 5x3; all that matters is that your convolutional output and your label properly match each other.

If you want the display (graph, picture, etc.) to match, perhaps you can just switch the x and y designations before you plot the output.