blob.hpp

namespace caffe { class Blob{} }

public:

  • Blob构造函数

    • Blob(): data_(), diff_(), count_(0), capacity_(0) {} Blob的构造函数
    • explicit Blob( const int num, const int channels, const int height, const int width)
    • explicit Blob( const vector< int>& shape)
  • Reshape() 调整shape函数

    • void Reshape( const int num, const int channels, const int height, const int width)
    • void Reshape(const vector< int>& shape) 改变blob的维数,如果需要则分配新的内存。该函数可被用做创建初始内存的分配,与在Reshape或Forward过程中,调整top blob的维数
    • void Reshape( const vector< int>& shape)
    • void Reshape( const BlobShape& shape)
  • void ReshapeLike( const Blob& other)

  • inline string shape_string() const {} 返回shape的具体参数

  • inline const vector< int>& shape() const {} 返回shape参数

  • inline int shape( int index) const{} 返回第index下标的维数

  • inline int num_axes() const {}

  • count() 返回总数

    • inline int count() const {}
    • inline int count( int start_axis, int end_axis) const{} 计算slice的volume,即在坐标中的维数乘积
    • inline int count( int start_axies) const {} 计算slice的volume,从特定的第一个到最后一个
    • inline int CanonicalAxisIndex( int axis_index) const{}
  • 返回shape[i]具体参数

    • inline int num() const{}
    • inline int channels() const{}
    • inline int height() const{}
    • inline int width() const{}
  • inline int LegacyShape( int index) const {}

  • offset() 返回偏移量

    • inline int offset( const int n, const int c=0, const int h=0, const int w=0) const {}
    • inline int offset( const vector< int>& indices) const{}
  • void CopyFrom( const Blob< Dtype>& source, bool copy_diff=false, bool reshape=false) 从source Blob复制。如果copy_diff为false,复制data,否则复制diff;如果reshape为true,Reshape这blob为其他shape

  • data_at()与diff_at()的表达

    • inline Dtype data_at( const int n, const int c, const int h,const int w) const {}
    • inline Dtype diff_at( const int n, const int c, const int h,const int w) const {}
    • inline Dtype data_at( const vector< int>& index) const {}
    • inline Dtype diff_at( const vector< int>& index) const {}
  • data()与diff()在内存的形式

    • inline const shared_ptr< SyncedMemory>& data() const {}
    • inline cosnt shared_ptr< SyncedMemory>& diff() const{}
  • cpu与gpu中,data()与diff()表达

    • const Dtype* cpu_data() const -void set_cpu_date( Dtype* data)
    • const Dtype* gpu_data() const
    • const Dtype* cpu_diff() const
    • const Dtype* gpu_diff() const
  • mutable_data()与mutable_diff()

    • Dtype* mutable_cpu_data()
    • Dtype* mutable_gpu_data()
    • Dtype* mutable_cpu_diff()
    • Dtype* mutable_gpu_diff()
  • void Update() 更新网络参数

  • void FromProto( const BlobProto& proto, bool reshape=true) 将配置参数从proto buffer中读取

  • void ToProto( BlobProto* proto, bool write_diff=false) const{} 将配置参数写进proto buffer中

  • asum_data()与asum_diff()

    • Dtype asum_data() const 计算data的绝对值之和(L1 norm)
    • Dtype asum_diff() const 计算diff的绝对值之和(L1 norm)
    • Dtype sumsq_data() const 计算data的平方和(L2 norm squared)
    • Dtype sumsq_diff() const 计算diff的平方和(L2 norm squared)
  • scale_data()与scale_diff()

    • void scale_data( Dtype scale_factor) 用固定系数scale data
    • void scale_diff( Dtype scale_factor) 用固定系数scale diff
  • void ShareData( const Blob& other) 设置data_为shared_ptr指向SyncedMemory,其保存Blob的data_

  • void ShareDiff( const Blob& other) 设置data_为shared_ptr指向SyncedMemory,其保存Blob的data_

  • bool ShapeEquals( const BlobProto& other)

protected:

  • shared_ptr< SyncedMemory> data_ 数据保存在data_中

  • shared_ptr diff_ 误差保存在diff_中

  • vector shape_ 具体参数保存在shape_

  • int count_ 需要总数目count_

  • int capacity_ 容量capacity_