caffe blob

类函数

返回形状信息bcwh
 inline const vector<int>& shape() const { return shape_; }
 返回index维度的大小
 inline int shape(int index) const {
    return shape_[CanonicalAxisIndex(index)];
  }
  返回shape的size
  inline int num_axes() const { return shape_.size(); }
  返回shape的total size
  inline 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",同理如上
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小涵涵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值