【caffe Layer】代码中文注释
src/caffe/proto/caffe.proto 中LayerParameter部分
// NOTE
// Update the next available ID when you add a new LayerParameter field.
// 如果增加一个新的LayerParameter域,需要更新下一个可用的ID
// LayerParameter next available layer-specific ID: 147 (last added: recurrent_param)
message LayerParameter {
optional string name = ; // the layer name 名称
optional string type = ; // the layer type 类型
repeated string bottom = ; // the name of each bottom blob 输入的Bottom Blob的名称
repeated string top = ; // the name of each top blob 输出的Top Blob名称 // The train / test phase for computation.当前阶段TRAIN或TEST
optional Phase phase = ; // The amount of weight to assign each top blob in the objective.
// Each layer assigns a default value, usually of either 0 or 1,
// to each top blob.
// 为每个输出Top Blob分配对损失函数的权重,每个Layer都有默认值,0表示不参与计算,1表示参与损失函数计算
repeated float loss_weight = ; // Specifies training parameters (multipliers on global learning constants,
// and the name and other settings used for weight sharing).
// 指定训练参数(例如相对全局学习常熟的缩放因子,以及用于权值共享的名称或其他设置)
repeated ParamSpec param = ; // The blobs containing the numeric parameters of the layer.
// 承载该曾数值参数的Blob
repeated BlobProto blobs = ; // Specifies whether to backpropagate to each bottom. If unspecified,
// Caffe will automatically infer whether each input needs backpropagation
// to compute parameter gradients. If set to true for some inputs,
// backpropagation to those inputs is forced; if set false for some inputs,
// backpropagation to those inputs is skipped.
// 是否对Bottom Blob进行反向传播过程。该字段维度应与Bottom Blob个数一致。
// The size must be either 0 or equal to the number of bottoms.
repeated bool propagate_down = ; // Rules controlling whether and when a layer is included in the network,
// based on the current NetState. You may specify a non-zero number of rules
// to include OR exclude, but not both. If no include or exclude rules are
// specified, the layer is always included. If the current NetState meets
// ANY (i.e., one or more) of the specified rules, the layer is
// included/excluded.
// 控制某个层在某个时刻是否包含在网络中(基于当前的NetState)
// 可以为include或exclude指定非零值(不能同时)
// 如果没有规则,该层一直包含在网络中
// 如果当前的NetState满足一定条件,那么该层被包含或被排斥
repeated NetStateRule include = ;
repeated NetStateRule exclude = ; // Parameters for data pre-processing. 数据预处理参数
optional TransformationParameter transform_param = ; // Parameters shared by loss layers. 所有损失层共享的参数
optional LossParameter loss_param = ; // Layer type-specific parameters.特定类型层参数
// 注意:一些层实现时可能有多于一种计算引擎,这些层通过选择引擎类型和引擎参数来实现。
// 默认引擎是在编译阶段由引擎开关设置的
// Note: certain layers may have more than one computational engine
// for their implementation. These layers include an Engine type and
// engine parameter for selecting the implementation.
// The default for the engine is set by the ENGINE switch at compile-time.
optional AccuracyParameter accuracy_param = ;
optional ArgMaxParameter argmax_param = ;
optional BatchNormParameter batch_norm_param = ;
optional BiasParameter bias_param = ;
optional ConcatParameter concat_param = ;
optional ContrastiveLossParameter contrastive_loss_param = ;
optional ConvolutionParameter convolution_param = ;
optional CropParameter crop_param = ;
optional DataParameter data_param = ;
optional DropoutParameter dropout_param = ;
optional DummyDataParameter dummy_data_param = ;
optional EltwiseParameter eltwise_param = ;
optional ELUParameter elu_param = ;
optional EmbedParameter embed_param = ;
optional ExpParameter exp_param = ;
optional FlattenParameter flatten_param = ;
optional HDF5DataParameter hdf5_data_param = ;
optional HDF5OutputParameter hdf5_output_param = ;
optional HingeLossParameter hinge_loss_param = ;
optional ImageDataParameter image_data_param = ;
optional InfogainLossParameter infogain_loss_param = ;
optional InnerProductParameter inner_product_param = ;
optional InputParameter input_param = ;
optional LogParameter log_param = ;
optional LRNParameter lrn_param = ;
optional MemoryDataParameter memory_data_param = ;
optional MVNParameter mvn_param = ;
optional ParameterParameter parameter_param = ;
optional PoolingParameter pooling_param = ;
optional PowerParameter power_param = ;
optional PReLUParameter prelu_param = ;
optional PythonParameter python_param = ;
optional RecurrentParameter recurrent_param = ;
optional ReductionParameter reduction_param = ;
optional ReLUParameter relu_param = ;
optional ReshapeParameter reshape_param = ;
optional ScaleParameter scale_param = ;
optional SigmoidParameter sigmoid_param = ;
optional SoftmaxParameter softmax_param = ;
optional SPPParameter spp_param = ;
optional SliceParameter slice_param = ;
optional TanHParameter tanh_param = ;
optional ThresholdParameter threshold_param = ;
optional TileParameter tile_param = ;
optional WindowDataParameter window_data_param = ;
}
include/caffe/layer.hpp
#ifndef CAFFE_LAYER_H_
#define CAFFE_LAYER_H_ #include <algorithm>
#include <string>
#include <vector> #include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/layer_factory.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/util/math_functions.hpp" /**
Forward declare boost::thread instead of including boost/thread.hpp
to avoid a boost/NVCC issues (#1009, #1010) on OSX.
*/
namespace boost { class mutex; } namespace caffe { /**
* @brief An interface for the units of computation which can be composed into a
* Net.
*
* Layer%s must implement a Forward function, in which they take their input
* (bottom) Blob%s (if any) and compute their output Blob%s (if any).
* They may also implement a Backward function, in which they compute the error
* gradients with respect to their input Blob%s, given the error gradients with
* their output Blob%s.
*/
template <typename Dtype>
class Layer {
public:
/**
* You should not implement your own constructor. Any set up code should go
* to SetUp(), where the dimensions of the bottom blobs are provided to the
* layer.
*/
// 显式构造函数,从LayerParameter中加载配置
explicit Layer(const LayerParameter& param)
: layer_param_(param) {
// Set phase and copy blobs (if there are any).
phase_ = param.phase();//设置当前阶段(训练或预测)
if (layer_param_.blobs_size() > ) {
blobs_.resize(layer_param_.blobs_size());
//按照layer_param_设置本身Blob对象个数,并依次把每个Blob对象尺寸调整为与layer_param_中Blob尺寸一致
for (int i = ; i < layer_param_.blobs_size(); ++i) {
blobs_[i].reset(new Blob<Dtype>());
blobs_[i]->FromProto(layer_param_.blobs(i));
}
}
}
virtual ~Layer() {} /**
* @brief Implements common layer setup functionality.
*
* @param bottom the preshaped input blobs
* @param top
* the allocated but unshaped output blobs, to be shaped by Reshape
*
* Checks that the number of bottom and top blobs is correct.
* Calls LayerSetUp to do special layer setup for individual layer types,
* followed by Reshape to set up sizes of top blobs and internal buffers.
* Sets up the loss weight multiplier blobs for any non-zero loss weights.
* This method may not be overridden.
*/
//配置函数,实现常用层配置借口,不可被覆盖
void SetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
CheckBlobCounts(bottom, top);//检查blob
LayerSetUp(bottom, top); //与层类型相关的配置过程
Reshape(bottom, top); //对TopBlob进行变形
SetLossWeights(top); //设置损失权值因子Blob
} /**
* @brief Does layer-specific setup: your layer should implement this function
* as well as Reshape.
*
* @param bottom
* the preshaped input blobs, whose data fields store the input data for
* this layer
* @param top
* the allocated but unshaped output blobs
*
* This method should do one-time layer specific setup. This includes reading
* and processing relevent parameters from the <code>layer_param_</code>.
* Setting up the shapes of top blobs and internal buffers should be done in
* <code>Reshape</code>, which will be called before the forward pass to
* adjust the top blob sizes.
*/
//层配置虚函数,做特定类型层相关配置,由该类型层自己实现
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {} /**
* @brief Adjust the shapes of top blobs and internal buffers to accommodate
* the shapes of the bottom blobs.
*
* @param bottom the input blobs, with the requested input shapes
* @param top the top blobs, which should be reshaped as needed
*
* This method should reshape top blobs as needed according to the shapes
* of the bottom (input) blobs, as well as reshaping any internal buffers
* and making any other necessary adjustments so that the layer can
* accommodate the bottom blobs.
*/
//纯虚函数。变形函数,修改Top Blob以及内部Blob缓冲区形状
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) = ; /**
* @brief Given the bottom blobs, compute the top blobs and the loss.
*
* @param bottom
* the input blobs, whose data fields store the input data for this layer
* @param top
* the preshaped output blobs, whose data fields will store this layers'
* outputs
* \return The total loss from the layer.
*
* The Forward wrapper calls the relevant device wrapper function
* (Forward_cpu or Forward_gpu) to compute the top blob values given the
* bottom blobs. If the layer has any non-zero loss_weights, the wrapper
* then computes and returns the loss.
*
* Your layer should implement Forward_cpu and (optionally) Forward_gpu.
*/
// 前向传播函数
// 给定Bottom Blob,计算TopBlob和loss,返回值为当前层的loss
// 该函数会调用相应设备包装函数,如Forward_cpu or Forward_gpu来实现真正计算过程
// 如果该层有非零loss权重参数,包装函数会计算并返回loss
// 派生类应该实现Forward_cpu,Forward_gpu(可选)
inline Dtype Forward(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top); /**
* @brief Given the top blob error gradients, compute the bottom blob error
* gradients.
*
* @param top
* the output blobs, whose diff fields store the gradient of the error
* with respect to themselves
* @param propagate_down
* a vector with equal length to bottom, with each index indicating
* whether to propagate the error gradients down to the bottom blob at
* the corresponding index
* @param bottom
* the input blobs, whose diff fields will store the gradient of the error
* with respect to themselves after Backward is run
*
* The Backward wrapper calls the relevant device wrapper function
* (Backward_cpu or Backward_gpu) to compute the bottom blob diffs given the
* top blob diffs.
*
* Your layer should implement Backward_cpu and (optionally) Backward_gpu.
*/
//反向传播函数
//给定输出的Top Blob误差梯度,计算输入的Bottom Blob的误差梯度
//propagate_down为多路开关,与Bottom Blob矢量维度相同,每个值表示是否将误差梯度传递到对应的Bottom Blob
//该函数会调用相应设备包装函数,如Backward_cpu and (可选) Backward_gpu实现计算过程,由派生类负责实现
inline void Backward(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom); /**
* @brief Returns the vector of learnable parameter blobs.
*/
vector<shared_ptr<Blob<Dtype> > >& blobs() {
return blobs_;//返回Layer内部可训练的权值、偏置项Blob向量
} /**
* @brief Returns the layer parameter.
*/
//返回Layer初始化参数(由ProtoBuffer提供)
const LayerParameter& layer_param() const { return layer_param_; } /**
* @brief Writes the layer parameter to a protocol buffer
*/
//将Layer初始化参数写入ProtoBuffer缓冲区
virtual void ToProto(LayerParameter* param, bool write_diff = false); /**
* @brief Returns the scalar loss associated with a top blob at a given index.
*/
//返回与某个Top Blob相关的标量loss值
inline Dtype loss(const int top_index) const {
return (loss_.size() > top_index) ? loss_[top_index] : Dtype();
} /**
* @brief Sets the loss associated with a top blob at a given index.
*/
//设置与某个Top Blob相关的标量loss值
inline void set_loss(const int top_index, const Dtype value) {
if (loss_.size() <= top_index) {
loss_.resize(top_index + , Dtype());
}
loss_[top_index] = value;
} /**
* @brief Returns the layer type.
*/
//返回层类型字符串,便于识别,由派生类实现
virtual inline const char* type() const { return ""; } /**
* @brief Returns the exact number of bottom blobs required by the layer,
* or -1 if no exact number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some exact number of bottom blobs.
*/
//返回Layer需要的输入Bottom Blob数目,-1表示不关心,需要派生类实现
virtual inline int ExactNumBottomBlobs() const { return -; }
/**
* @brief Returns the minimum number of bottom blobs required by the layer,
* or -1 if no minimum number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some minimum number of bottom blobs.
*/
virtual inline int MinBottomBlobs() const { return -; }
/**
* @brief Returns the maximum number of bottom blobs required by the layer,
* or -1 if no maximum number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some maximum number of bottom blobs.
*/
virtual inline int MaxBottomBlobs() const { return -; }
/**
* @brief Returns the exact number of top blobs required by the layer,
* or -1 if no exact number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some exact number of top blobs.
*/
//返回Layer需要的输出Top Blob数目,-1表示不关心,需要派生类实现
virtual inline int ExactNumTopBlobs() const { return -; }
/**
* @brief Returns the minimum number of top blobs required by the layer,
* or -1 if no minimum number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some minimum number of top blobs.
*/
virtual inline int MinTopBlobs() const { return -; }
/**
* @brief Returns the maximum number of top blobs required by the layer,
* or -1 if no maximum number is required.
*
* This method should be overridden to return a non-negative value if your
* layer expects some maximum number of top blobs.
*/
virtual inline int MaxTopBlobs() const { return -; }
/**
* @brief Returns true if the layer requires an equal number of bottom and
* top blobs.
*
* This method should be overridden to return true if your layer expects an
* equal number of bottom and top blobs.
*/
//返回Layer是否有相同的输入输出Blob,需要派生类实现
virtual inline bool EqualNumBottomTopBlobs() const { return false; } /**
* @brief Return whether "anonymous" top blobs are created automatically
* by the layer.
*
* If this method returns true, Net::Init will create enough "anonymous" top
* blobs to fulfill the requirement specified by ExactNumTopBlobs() or
* MinTopBlobs().
*/
//返回是否允许匿名Top Blob,即由该层自动创建。
//如果为真,Net::Init 会创建足够多的匿名Top Blob来满足 ExactNumTopBlobs() or MinTopBlobs()需求
virtual inline bool AutoTopBlobs() const { return false; } /**
* @brief Return whether to allow force_backward for a given bottom blob
* index.
*
* If AllowForceBackward(i) == false, we will ignore the force_backward
* setting and backpropagate to blob i only if it needs gradient information
* (as is done when force_backward == false).
*/
//是否允许强制反向传播。如果AllowForceBackward(i) == false,忽略force_backward设定
virtual inline bool AllowForceBackward(const int bottom_index) const {
return true;
} /**
* @brief Specifies whether the layer should compute gradients w.r.t. a
* parameter at a particular index given by param_id.
*
* You can safely ignore false values and always compute gradients
* for all parameters, but possibly with wasteful computation.
*/
//该Layer是否计算相对权值或偏置项的梯度,具体相对谁由param_id指定
inline bool param_propagate_down(const int param_id) {
return (param_propagate_down_.size() > param_id) ?
param_propagate_down_[param_id] : false;
}
/**
* @brief Sets whether the layer should compute gradients w.r.t. a
* parameter at a particular index given by param_id.
*/
//设置该Layer是否计算相对权值或偏置项的梯度,具体相对谁由param_id指定
inline void set_param_propagate_down(const int param_id, const bool value) {
if (param_propagate_down_.size() <= param_id) {
param_propagate_down_.resize(param_id + , true);
}
param_propagate_down_[param_id] = value;
} protected:
/** The protobuf that stores the layer parameters */
LayerParameter layer_param_;//保存Layer参数的ProtoBuffer对象
/** The phase: TRAIN or TEST */
Phase phase_;//Layer当前所属阶段,可选TRAIN或TEST
/** The vector that stores the learnable parameters as a set of blobs. */
vector<shared_ptr<Blob<Dtype> > > blobs_;//Layer内部权值偏置项,由Blob组织
/** Vector indicating whether to compute the diff of each param blob. */
vector<bool> param_propagate_down_;//标志位,是否计算对应的参数的误差梯度 /** The vector that indicates whether each top blob has a non-zero weight in
* the objective function. */
vector<Dtype> loss_;//标志位,在目标函数中是否每个Top Blob都有非零权值 //以下四个函数会在派生类中经常看到 /** @brief Using the CPU device, compute the layer output. */
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) = ;
/**
* @brief Using the GPU device, compute the layer output.
* Fall back to Forward_cpu() if unavailable.
*/
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
// LOG(WARNING) << "Using CPU code as backup.";
return Forward_cpu(bottom, top);
} /**
* @brief Using the CPU device, compute the gradients for any parameters and
* for the bottom blobs if propagate_down is true.
*/
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) = ;
/**
* @brief Using the GPU device, compute the gradients for any parameters and
* for the bottom blobs if propagate_down is true.
* Fall back to Backward_cpu() if unavailable.
*/
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) {
// LOG(WARNING) << "Using CPU code as backup.";
Backward_cpu(top, propagate_down, bottom);
} /**
* Called by the parent Layer's SetUp to check that the number of bottom
* and top Blobs provided as input match the expected numbers specified by
* the {ExactNum,Min,Max}{Bottom,Top}Blobs() functions.
*/
//校验输入输出Blob数目是否满足Layer要求
virtual void CheckBlobCounts(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
if (ExactNumBottomBlobs() >= ) {
CHECK_EQ(ExactNumBottomBlobs(), bottom.size())
<< type() << " Layer takes " << ExactNumBottomBlobs()
<< " bottom blob(s) as input.";
}
if (MinBottomBlobs() >= ) {
CHECK_LE(MinBottomBlobs(), bottom.size())
<< type() << " Layer takes at least " << MinBottomBlobs()
<< " bottom blob(s) as input.";
}
if (MaxBottomBlobs() >= ) {
CHECK_GE(MaxBottomBlobs(), bottom.size())
<< type() << " Layer takes at most " << MaxBottomBlobs()
<< " bottom blob(s) as input.";
}
if (ExactNumTopBlobs() >= ) {
CHECK_EQ(ExactNumTopBlobs(), top.size())
<< type() << " Layer produces " << ExactNumTopBlobs()
<< " top blob(s) as output.";
}
if (MinTopBlobs() >= ) {
CHECK_LE(MinTopBlobs(), top.size())
<< type() << " Layer produces at least " << MinTopBlobs()
<< " top blob(s) as output.";
}
if (MaxTopBlobs() >= ) {
CHECK_GE(MaxTopBlobs(), top.size())
<< type() << " Layer produces at most " << MaxTopBlobs()
<< " top blob(s) as output.";
}
if (EqualNumBottomTopBlobs()) {
CHECK_EQ(bottom.size(), top.size())
<< type() << " Layer produces one top blob as output for each "
<< "bottom blob input.";
}
} /**
* Called by SetUp to initialize the weights associated with any top blobs in
* the loss function. Store non-zero loss weights in the diff blob.
*/
//该函数在Layer的Setup函数中调用,主要目的是初始化与TopBlob相关的loss权重,放到top blob的diff域
//实际由Forward()计算loss
//loss_weight==0 表示当前层不参与loss计算,大部分layer属于这一类
//loss_weight==1 表示当前层参与loss计算,损失层(LossLayer)属于这一类
inline void SetLossWeights(const vector<Blob<Dtype>*>& top) {
//从ProtoBuffer对象中获得Layer参数,这里需要loss_weight参数
const int num_loss_weights = layer_param_.loss_weight_size();
if (num_loss_weights) {//如果ProtoBuffer中至少有一个loss_weight 参数
//loss_weight个数应该与TopBlob相同,或者不要Loss_weigth参数
CHECK_EQ(top.size(), num_loss_weights) << "loss_weight must be "
"unspecified or specified once per top blob.";
//遍历每一个Top Blob
for (int top_id = ; top_id < top.size(); ++top_id) {
//从ProtoBuffer对象中获得loss_weight参数(0或者1)
const Dtype loss_weight = layer_param_.loss_weight(top_id);
if (loss_weight == Dtype()) { continue; }//为0,跳过
this->set_loss(top_id, loss_weight);//不为0,进行网络的相关设置
const int count = top[top_id]->count();//本地记录loss_weight的值
Dtype* loss_multiplier = top[top_id]->mutable_cpu_diff();
//将loss_weight写入TopBlob的diff中,传递到需要使用的地方,实现远程同步
caffe_set(count, loss_weight, loss_multiplier);
}
}
} private:
DISABLE_COPY_AND_ASSIGN(Layer);//禁用拷贝构造函数和赋值运算函数
}; // class Layer // Forward and backward wrappers. You should implement the cpu and
// gpu specific implementations instead, and should not change these
// functions.
//前向传播函数、后向传播函数的包装,不需要修改这两个函数
//使用时只需要在派生类中改写Forward_cpu等
template <typename Dtype>
inline Dtype Layer<Dtype>::Forward(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
Dtype loss = ;
Reshape(bottom, top);
switch (Caffe::mode()) {//判断计算设备
case Caffe::CPU://在CPU上执行Forward计算
Forward_cpu(bottom, top);//调用CPU版本的Forward
//如果需要计算loss还需要进一步操作
for (int top_id = ; top_id < top.size(); ++top_id) {
if (!this->loss(top_id)) { continue; }
const int count = top[top_id]->count();
//若为损失层,则已经通过Forward函数计算出全局损失函数,放在Top Blob data中
const Dtype* data = top[top_id]->cpu_data();
//若loss_weight不为0,则已经在SetLossWeight中将loss权重放在Top Blob diff 中
const Dtype* loss_weights = top[top_id]->cpu_diff();
loss += caffe_cpu_dot(count, data, loss_weights);//加权loss之和,得到标量loss
}
break;
case Caffe::GPU:
Forward_gpu(bottom, top);
#ifndef CPU_ONLY
for (int top_id = ; top_id < top.size(); ++top_id) {
if (!this->loss(top_id)) { continue; }
const int count = top[top_id]->count();
const Dtype* data = top[top_id]->gpu_data();
const Dtype* loss_weights = top[top_id]->gpu_diff();
Dtype blob_loss = ;
caffe_gpu_dot(count, data, loss_weights, &blob_loss);
loss += blob_loss;
}
#endif
break;
default:
LOG(FATAL) << "Unknown caffe mode.";
}
return loss;
}
//反向传播函数,直接调用对应设备函数
template <typename Dtype>
inline void Layer<Dtype>::Backward(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) {
switch (Caffe::mode()) {
case Caffe::CPU:
Backward_cpu(top, propagate_down, bottom);
break;
case Caffe::GPU:
Backward_gpu(top, propagate_down, bottom);
break;
default:
LOG(FATAL) << "Unknown caffe mode.";
}
}
//将层配置参数序列化为ProtoBuffer
// Serialize LayerParameter to protocol buffer
template <typename Dtype>
void Layer<Dtype>::ToProto(LayerParameter* param, bool write_diff) {
param->Clear();
param->CopyFrom(layer_param_);
param->clear_blobs();
for (int i = ; i < blobs_.size(); ++i) {
blobs_[i]->ToProto(param->add_blobs(), write_diff);
}//权值偏置项也会保存
} } // namespace caffe #endif // CAFFE_LAYER_H_
待更新
摘抄参考赵永科《深度学习 21天实战caffe》
【caffe Layer】代码中文注释的更多相关文章
- 去掉VS2010代码中文注释的红色下划线
VS2010代码中文注释出现红色下划线,代码看上去很不美观,发现是由于安装Visual Assist X插件造成的. 解决办法:打开VAX的Options对话框,取消Advanced --> U ...
- 【caffe Net】使用举例和代码中文注释
首先是Net使用的小例子: #include <vector> #include <iostream> #include <caffe/net.hpp> using ...
- 【caffe I/O】数据读取层 代码中文注释
caffe.proto中DataParameter部分 message DataParameter { //输入数据使用的DB类型 enum DB { LEVELDB = ;//使用LEVELDB L ...
- 关闭shift中英文切换 英文代码/中文注释随意切换着写。
x 背景 写代码的时候总是意外的就切成中文了,特别是代码中大小写切换的这种情况... 例如:"public static TimeZone CurrentTime..."publi ...
- WIdo联网代码中文注释
代码如下 /*************************************************** 这是一个例子的dfrobot维多-无线集成物联网建兴传感器和控制节点 *产品页面及更 ...
- [转载]将别人的项目或JAVA文件导入到自己的Eclipse中时,常常会出现JAVA文件的中文注释变成乱码的情况,解决办法
eclipse 代码中文注释乱码 求解决 将别人的项目或JAVA文件导入到自己的Eclipse中时,常常会出现JAVA文件的中文注释变成乱码的情况,主要原因就是别人的IDE编码格式和自己的Eclips ...
- mysql代码里面有中文注释导致语法错误
一个简单的创建表的代码 DROP database IF exists reg_login; CREATE database reg_login; use reg_login --用户表 create ...
- Visual Studio vs2010 去掉中文注释红色下划线;去掉代码红色下划线;
vs去掉下挂线也分两种: 1.去掉中文注释红色下划线,需要去掉VisualAssist下划线鸡肋功能: 1.选择Visual AssistX Options: 2.把如图所示的勾去掉,解决. 以后再次 ...
- C++格式化代码,去掉vs2010编辑器里中文注释的红色波浪线
原文:http://sulianqi.cn/Article/ART2013053100001.html Vs2010中C++没有智能感应提示,不习惯,于是装了个番茄插件(Visual Assist x ...
随机推荐
- 【转载】C#中ToArray方法将List集合转换为对应的数组
在C#的List集合操作中,可以使用List集合自带的ToArray方法来将List集合转换为对应的Array数组元素.ToArray方法的签名为T[] ToArray(),存在于命名空间System ...
- 浅析JavaScript异步
一直以来都知道JavaScript是一门单线程语言,在笔试过程中不断的遇到一些输出结果的问题,考量的是对异步编程掌握情况.一般被问到异步的时候脑子里第一反应就是Ajax,setTimseout...这 ...
- 装饰器带类参数 & 一个函数应用多个装饰器
装饰器:不改变原函数的基础上,给函数增加功能的方式,称为装饰器 即:为已经存在的对象添加额外的功能 装饰器其实就是一个闭包,把一个函数当做参数后返回一个替代版的函数 decos.py:(装饰器的参数类 ...
- JavaScript之控制标签内容
function abb(a){ return document.getElementById(a); } console.log(abb('box').innerHTML); 标签.innerHTM ...
- python(数据精度处理)
一.取整处理 1.int() 向下取整 内置函数 1 n = 3.75 2 print(int(n))>>> 3 3 n = 3.25 4 print(int(n))>> ...
- FSMN 及其变种 cFSMN DFSMN pyramidal-FSMN
原文: https://blog.csdn.net/qq_26778411/article/details/89682447 也可以参考: http://vsooda.github.io/2018/ ...
- 使用Cloudera Manager部署HUE
使用Cloudera Manager部署HUE 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.添加HUE服务 1>.进入CM服务安装向导 2>.选择需要安装的h ...
- 二叉树(python)
# -*- coding: utf-8 -*- from collections import deque class Queue(object): def __init__(self): self. ...
- PHP高手干货分享:不能不看的50个细节!
1.用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量, 单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的”函数”(译注:PHP手 ...
- npm安装模块没有权限解决办法
直接加上unsafe的参数即可 sudo npm install --unsafe-perm --verbose -g sails