protected: // 这个 Net 的名称 string name_; // 这个 Net 用于 TRAIN or TEST Phase phase_; // 记录这个 Net 中的每一层 vector<shared_ptr<Layer<Dtype>>> layers_; // 记录每一层的名称 vector<string> layer_names_; // 记录每一层与其位置Index的对应关系 map<string, int> layer_names_index_; // 记录每层是否需要反向传播 vector<bool> layer_need_backward_;
// 存储层之间的中间结果 vector<shared_ptr<Blob<Dtype>>> blobs_; // 记录每个blob的名称 vector<string> blob_names_; // 记录每个Blob与其位置Index的对应关系 map<string, int> blob_names_index_; // 记录每个blob是否需要反向计算 vector<bool> blob_need_backward_; /// bottom_vecs stores the vectors containing the input for each layer. /// They don't actually host the blobs (blobs_ does), so we simply store /// pointers. // 记录每个Layer的输入Blob,但并不是Blob的内容,而是Blob的地址。 vector<vector<Blob<Dtype>*>> bottom_vecs_; // 与上者相关, vector<vector<int>> bottom_id_vecs_; vector<vector<bool>> bottom_need_backward_; /// top_vecs stores the vectors containing the output for each layer vector<vector<Blob<Dtype>*>> top_vecs_; vector<vector<int>> top_id_vecs_; /// Vector of weight in the loss (or objective) function of each net blob, /// indexed by blob_id. vector<Dtype> blob_loss_weights_;
/// blob indices for the input and the output of the net // 这个Net 的输入输出Blob 在 blobs_ 中的索引 vector<int> net_input_blob_indices_; vector<int> net_output_blob_indices_; // 输入输出Blob vector<Blob<Dtype>*> net_input_blobs_; vector<Blob<Dtype>*> net_output_blobs_;
// 这个 Net 中的参数,权值 vector<shared_ptr<Blob<Dtype>>> params_; // 这个 Net 中可训练的权值 vector<Blob<Dtype>*> learnable_params_; /** * The mapping from params_ -> learnable_params_: we have * learnable_param_ids_.size() == params_.size(), * and learnable_params_[learnable_param_ids_[i]] == params_[i].get() * if and only if params_[i] is an "owner"; otherwise, params_[i] is a sharer * and learnable_params_[learnable_param_ids_[i]] gives its owner. */ vector<int> learnable_param_ids_; /// the learning rate multipliers for learnable_params_ vector<float> params_lr_; vector<bool> has_params_lr_; /// the weight decay multipliers for learnable_params_ vector<float> params_weight_decay_; vector<bool> has_params_decay_; /// The bytes of memory used by this net size_t memory_used_; /// Whether to compute and display debug info for the net. bool debug_info_; // Callbacks vector<Callback*> before_forward_; vector<Callback*> after_forward_; vector<Callback*> before_backward_; vector<Callback*> after_backward_;