How Caffe implicitly do reshape on a blob before doing fully connecting calculation?

382 views Asked by At

How does Caffe implicitly do reshape on a blob before doing fully connecting calculation?

1

There are 1 answers

1
Shai On

"InnerProduct" layer (aka "fully connected") has a axis: parameter that defines how caffe "flattens" the blob for the inner product.
You can see in inner_product_layer.cpp:

// Dimensions starting from "axis" are "flattened" into a single
// length K_ vector. For example, if bottom[0]'s shape is (N, C, H, W),
// and axis == 1, N inner products with dimension CHW are performed.

Since caffe stores Blobs contiguously in memory, no explicit reshape is needed for "flattening" the trailing dimensions of a blob.