Wrp Yuexia
Wrp Yuexia

Reputation: 103

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

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

Upvotes: 1

Views: 384

Answers (1)

Shai
Shai

Reputation: 114866

"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.

Upvotes: 2

Related Questions