sad

作者: cheng_wang1987 | 来源:发表于2015-08-02 04:02 被阅读0次

How to add a new layer on caffe network?

The official but outdated document

can be found:https://github.com/BVLC/caffe/wiki/Developmentand

useful links:https://yunmingzhang.wordpress.com/2015/01/19/how-to-create-your-own-layer-in-deep-learning-framework-caffe/

In this work, we try to add a verysimple layer: a linear function f(x)=0.5(x)+0.1 as activation layer (justsimilar to sigma and tahn) to illustrate the way to add new layer to Caffe.

Step 1: you should create a newclass in caffe_root/inclide/caffexx.hppfile.

Similar to sigma, it should be addedto neuron_layers.hpp

If you want to use GPU version,uncomment gpu functions and implement it in linear_layer.cu

Step2: Assign new ID to your layer

Incaffe_root/src/caffe/proto/caffe.proto, we define our layer as LINEAR andassign ID=38 (can be other number), meanwhile, we assign layer parameter ID

Setp 3: Implement linear layer incaffe_root/src/caffe/layers.

Create a new .cpp file as“linear_layer.cpp”,there are fourmethods might be implemented

·LayerSetUp(optional): for

one-time initialization: reading parameters, fixed-size allocations, etc.

·Reshape:for computing the sizes of top blobs,allocating buffers, and any other work that depends on the shapes of bottomblobs

·Forward_cpu:for the

function your layer computes

·Backward_cpu:for its

gradient (Optional -- a layer can be forward-only)

Here, we implement CPU version ofForward and Backward

Step 4: Instantiate and register

your layer in your cpp file with the macro provided inlayer_factory.hpp.

Step 5: add newlayer to train_test_prototxt,compileand run!

��*���G�

相关文章

  • Day 39

    sad……sad……sad……

  • Sadless

    sad I am sad Something joys me

  • The  sad

    If one day,you into my heart ,you'll cry .Because is the...

  • sad

    https://www.zhihu.com/question/20624099

  • be sad

    worry about nothing pray about everything 真的不用担心吗? 这种情绪不是...

  • sad

    跟父母没有和解的话,这颗心就好不了了吧。

  • sad

    无法形容,我自己都不想吐槽我自己了,两年前的我甚至无法想想自己会过成这样,思想上会有这样的烦恼,做了这么多后悔事。...

  • sad

    今天重感冒了 好难受 鼻子堵着鼻涕 喉咙也痰还疼 呜呜呜 委屈死了

  • sad

    和开心点一样难的是早点睡。 是个比较自卑的人了,源自于方方面面,是很想成为更好的自己的,可是我仅有的一点点自制力不...

  • sad

    明天就要被卖掉了

网友评论

      本文标题:sad

      本文链接:https://www.haomeiwen.com/subject/iylvqttx.html