caffe 原始碼分析【二】:Layer基類
阿新 • • 發佈:2018-11-10
建構函式
//標頭檔案 include/caffe/layer.hpp
//實現檔案 src/caffe/layer.cpp
// src/caffe/layer.cu
/*
* 建構函式
* 子類中修改建構函式,自定義設定在SetUp()中設定
*/
explicit Layer(const LayerParameter ¶m)
protect 變數
/** The protobuf that stores the layer parameters */ //儲存layer引數的protobuf物件 LayerParameter layer_param_; /** The phase: TRAIN or TEST */ //哪個階段, TRAIN還是TEST Phase phase_; /** The vector that stores the learnable parameters as a set of blobs. */ //blobs,儲存需要學習的的引數 vector<shared_ptr<Blob<Dtype> > > blobs_; /** Vector indicating whether to compute the diff of each param blob. */ //陣列,表徵需要學習的引數blob是否需要計算梯度 vector<bool> param_propagate_down_; /** The vector that indicates whether each top blob has a non-zero weight in * the objective function. */ //陣列,表徵每個top blob是否在目標函式中具有非零權重 vector<Dtype> loss_;
常見操作:
//ReshapLike(),輸入與輸出層形狀保持一致
top[0]->ReshapeLike(*bottom[0]);