caffe blob
- 类函数
-
- CanonicalAxisIndex(int axis_index)
- LegacyShape(int index)
- TIP
类函数
返回形状信息bcwhinline const vector<int>& shape() const {
return shape_; }返回index维度的大小inline int shape(int index) const {
return shape_[CanonicalAxisIndex(index)];}返回shape的sizeinline int num_axes() const {
return shape_.size(); }返回shape的total sizeinline int count() const {
return count_; }
CanonicalAxisIndex(int axis_index)
CanonicalAxisIndex()函数根据index的正负返回对应的index正值.
inline int CanonicalAxisIndex(int axis_index) const {
CHECK_GE(axis_index, -num_axes())<< "axis " << axis_index << " out of range for " << num_axes()<< "-D Blob with shape " << shape_string();CHECK_LT(axis_index, num_axes())<< "axis " << axis_index << " out of range for " << num_axes()<< "-D Blob with shape " << shape_string();if (axis_index < 0) {
return axis_index + num_axes();}return axis_index;}
LegacyShape(int index)
LegacyShape(int index)返回index出shape的大小
inline int LegacyShape(int index) const {
CHECK_LE(num_axes(), 4)<< "Cannot use legacy accessors on Blobs with > 4 axes.";CHECK_LT(index, 4);CHECK_GE(index, -4);if (index >= num_axes() || index < -num_axes()) {
// Axis is out of range, but still in [0, 3] (or [-4, -1] for reverse// indexing) -- this special case simulates the one-padding used to fill// extraneous axes of legacy blobs.return 1;}return shape(index);}
TIP
CHECK_EQ(x,y)<<"x!=y",EQ即equation,意为“等于”,函数判断是否x等于y,当x!=y时,函数打印出x!=y。CHECK_NE(x,y)<<"x=y",NE即not equation,意为“不等于”,函数判断是否x不等于y,当x=y时,函数打印出x=y。CHECK_LE(x,y) <<"x<=y",LE即lower equation,意为小于等于,函数判断是否x小于等于y。当x<=y时,函数打印x<=y。CHECK_LT(x,y)<<"x<=y",LT即为lower to ,意为小于,函数判断是否x小于y,当x<y时,函数打印x<y。CHECK_GE(x,y) <<"x>=y",GE即为great equation,意为大于。CHECK_GT(x,y) <<"x>=y",同理如上