Skip to content

Instantly share code, notes, and snippets.

@soulslicer
Created February 19, 2017 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulslicer/3c0afcf5a3e8e401d106e77b453ec0af to your computer and use it in GitHub Desktop.
Save soulslicer/3c0afcf5a3e8e401d106e77b453ec0af to your computer and use it in GitHub Desktop.
caffe::BlobProto blob_proto;
blob_proto.set_num(1);
blob_proto.set_channels(3);
blob_proto.set_height(224);
blob_proto.set_width(224);
blob_proto.clear_data();
for (int c = 0; c < 3; ++c) {
for (int h = 0; h < 224; ++h) {
for (int w = 0; w < 224; ++w) {
cv::Vec3f& vec = conv.at<cv::Vec3f>(h,w);
blob_proto.add_data(conv.at<cv::Vec3b>(h, w)[c]);
}
}
}
input_layer->FromProto(blob_proto);
std::vector<boost::shared_ptr<caffe::Blob<float> > >& layer = net_.layer_by_name("data")->blobs();
net_.Forward();
std::vector<std::string> layerNames = net_.layer_names();
for(int i=0; i<layerNames.size(); i++){
cout << layerNames[i] << endl;
std::vector<boost::shared_ptr<caffe::Blob<float> > >& layer = net_.layer_by_name(layerNames[i])->blobs();
cout << layer.size() << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment