luoyetx / mini-caffe

Minimal runtime core of Caffe, Forward only, GPU support and Memory efficiency.
BSD 3-Clause "New" or "Revised" License
374 stars 151 forks source link

How to add a new layer? #47

Closed Li-Lai closed 7 years ago

Li-Lai commented 7 years ago

Thank you for sharing the code. Could you tell me how to add a new layer in min-caffe? Is it the same as caffe?

luoyetx commented 7 years ago

It's the same as Official Caffe. Please refer to proposal_layer.hpp. The default data type is float.

Li-Lai commented 7 years ago

Thanks for your reply. If I use the code for classification task, then i need to get the final layer values (type: Softmax). The following code is right? ` vector get_values(layer_values->count());

for (int i = 0; i < layer_values->count(); i++)

{

    float &get_value = get_values[i];

    get_value = layer_values->data_at(0, i, 0, 0);####?

    cout << "get_value:" << get_value << endl;

}

`

luoyetx commented 7 years ago

Assume you have the net definition like below

layer {
  name: "prob-layer"
  type: "Softmax"
  bottom: "score"
  top: "prob"
}

Then you should get the output from Blob prob.

shared_ptr<Blob> prob = net->blob_by_name("prob");
for (int i = 0; i < prob->count(); i++) {
...
}
luoyetx commented 7 years ago

@CBIR-LL For more details, Please refer to examples

Li-Lai commented 7 years ago

Thanks. I'll take a good look at your examples.