caffe filler
2015-08-20 11:38
155 查看
cnn 网络权值的初始化方式有很多种, caffe 里面实现了7种, 在include/caffe/filler.hpp。caffe::Filler< Dtype > Class Template ReferenceabstractFills a Blob withconstant or randomly-generated data. More...![](http://caffe.berkeleyvision.org/doxygen/classcaffe_1_1Filler.png)
#include <filler.hpp>Inheritance diagram for caffe::Filler< Dtype >:
![](http://caffe.berkeleyvision.org/doxygen/classcaffe_1_1Filler.png)
Public Member Functions | |
Filler (const FillerParameter ¶m) | |
virtual void | Fill (Blob< Dtype > *blob)=0 |
Protected Attributes | |
FillerParameter | filler_param_ |
Detailed Description
template<typename Dtype>class caffe::Filler< Dtype >
Fills a Blob withconstant or randomly-generated data.The documentation for this class was generated from the following file:include/caffe/filler.hppFiller<Dtype>* GetFiller(const FillerParameter& param) { const std::string& type = param.type(); if (type == "constant") { return new ConstantFiller<Dtype>(param); } else if (type == "gaussian") { return new GaussianFiller<Dtype>(param); } else if (type == "positive_unitball") { return new PositiveUnitballFiller<Dtype>(param); } else if (type == "uniform") { return new UniformFiller<Dtype>(param); } else if (type == "xavier") { return new XavierFiller<Dtype>(param); } else if (type == "msra") { return new MSRAFiller<Dtype>(param); } else if (type == "bilinear") { return new BilinearFiller<Dtype>(param); } else { CHECK(false) << "Unknown filler name: " << param.type(); } return (Filler<Dtype>*)(NULL); }共有七种方法, 下面分别介绍一下:(1) constant
template <typename Dtype> class ConstantFiller : public Filler<Dtype> { public: explicit ConstantFiller(const FillerParameter& param) : Filler<Dtype>(param) {} virtual void Fill(Blob<Dtype>* blob) { Dtype* data = blob->mutable_cpu_data(); const int count = blob->count(); // get prototxt filler parameters value const Dtype value = this->filler_param_.value(); // 得到配置文件中 设置的值 CHECK(count); for (int i = 0; i < count; ++i) { data[i] = value; // 将配置文件中的值,直接赋值到 data中。 所以 是常量型,就是配置文件常量 }<pre name="code" class="cpp">(2) UniformFiller
<pre name="code" class="cpp"><pre name="code" class="cpp">/// @brief Fills a Blob with uniformly distributed values @f$ x\sim U(a, b) @f$.template <typename Dtype>class UniformFiller : public Filler<Dtype> {public:explicit UniformFiller(const FillerParameter& param): Filler<Dtype>(param) {}virtual void Fill(Blob<Dtype>* blob) {CHECK(blob->count());caffe_rng_uniform<Dtype>(blob->count(), Dtype(this->filler_param_.min()), //调用 caffe_rng_uniform ,这个在math_funtion 中实现Dtype(this->filler_param_.max()), blob->mutable_cpu_data());CHECK_EQ(this->filler_param_.sparse(), -1)<< "Sparsity not supported by this Filler.";}};CHECK_EQ(this->filler_param_.sparse(), -1) << "Sparsity not supported by this Filler."; }};
相关文章推荐
- HTML5 Boilerplate笔记(3)
- HTML5 Boilerplate笔记(2)(转)
- SharePoint 2013 IT Professional——逻辑结构
- css3鼠标经过图片放大
- js实现网页多级级联菜单代码
- html中的meta标签作用
- Windows_X64 + ATI显卡 + VS2013 安装Caffe
- Javascript(一)-20-(JS函数_练习2)
- Javascript(一)-18-(JS函数_匿名函数)
- Javascript(一)-19-(JS函数_练习1)
- Javascript(一)-17-(JS函数_动态函数)
- js,addEventListener参数传递
- Javascript(一)-16-(JS函数_细节2)
- Javascript(一)-15-(JS函数_细节1)
- Javascript(一)-14-(JS函数)
- Javascript(一)-13-(JS数组)
- javascript常用的方法整理
- Javascript(一)-12-(JS语句-练习-九九乘法表)
- Javascript(一)-11-(JS语句-其他语句)
- Javascript(一)-10-(JS语句-循环语句)