Bharat
Bharat

Reputation: 2179

Sum elements in a channel in caffe

If I have a 4-D blob, say of size (40,1024,300,1) and I want to average pool across the second channel and generate an output of size (40,1,300,1), how would I do it? I think the reduction layer collapses the whole blob and generates a blob of size (40) by summing elements in all other axises (after 1) also. Is there any work around for this without re-implementing a new layer?

Upvotes: 1

Views: 508

Answers (1)

Autonomous
Autonomous

Reputation: 9075

The only easy workaround I found is as follows. Permute your blob to a shape (40,300,1,1024). Use reduction layer to compute the mean with axis = -1 and operation = MEAN. I think the blob will be of shape (40,300,1). You may need to use reshape to append an extra dimension at the end (check if this is needed) and then permute back to shape (40,1,300,1).

You can find an implementation of a Permute layer here or here. I hope this helps.

Upvotes: 2

Related Questions