本文整理汇总了C++中Net::layer_names方法的典型用法代码示例。如果您正苦于以下问题:C++ Net::layer_names方法的具体用法?C++ Net::layer_names怎么用?C++ Net::layer_names使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net
的用法示例。
在下文中一共展示了Net::layer_names方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: net_get_loss_diff
static void net_get_loss_diff(MEX_ARGS) {
mxCHECK(nrhs == 2 && mxIsStruct(prhs[0]),"Usage: caffe_('net_get_loss_diff', hNet, layer_index)");
Net<float>* net = handle_to_ptr<Net<float> >(prhs[0]);
int layer_idx = *((int*)mxGetData(prhs[1]));
shared_ptr<EuclideanLossLayer<float> > loss = boost::dynamic_pointer_cast< EuclideanLossLayer<float> >(net->layers()[layer_idx-1]);
if (!loss) {
const vector< string > net_layer_names = net->layer_names();
mexPrintf("layer_name: %s\n",(net_layer_names[layer_idx]).c_str());
mxERROR("net_get_jacobian may only be called if the layer is a EuclideanLossLayer");
}else{
mexPrintf("Found loss layer...\n");
}
Blob<float> tmp_loss_diff(loss->Get_diff_shape(0), loss->Get_diff_shape(1), loss->Get_diff_shape(2), loss->Get_diff_shape(3));
Blob<float>* actual_diff= (Blob<float>*)loss->Get_internal_diff();
(&tmp_loss_diff)->CopyFrom(*actual_diff);
plhs[0] = blob_to_mx_mat(&tmp_loss_diff, DATA);
}
示例2: net_get_attr
// Usage: caffe_('net_get_attr', hNet)
static void net_get_attr(MEX_ARGS) {
mxCHECK(nrhs == 1 && mxIsStruct(prhs[0]),
"Usage: caffe_('net_get_attr', hNet)");
Net<float>* net = handle_to_ptr<Net<float> >(prhs[0]);
const int net_attr_num = 6;
const char* net_attrs[net_attr_num] = { "hLayer_layers", "hBlob_blobs",
"input_blob_indices", "output_blob_indices", "layer_names", "blob_names" };
mxArray* mx_net_attr = mxCreateStructMatrix(1, 1, net_attr_num,
net_attrs);
mxSetField(mx_net_attr, 0, "hLayer_layers",
ptr_vec_to_handle_vec<Layer<float> >(net->layers()));
mxSetField(mx_net_attr, 0, "hBlob_blobs",
ptr_vec_to_handle_vec<Blob<float> >(net->blobs()));
mxSetField(mx_net_attr, 0, "input_blob_indices",
int_vec_to_mx_vec(net->input_blob_indices()));
mxSetField(mx_net_attr, 0, "output_blob_indices",
int_vec_to_mx_vec(net->output_blob_indices()));
mxSetField(mx_net_attr, 0, "layer_names",
str_vec_to_mx_strcell(net->layer_names()));
mxSetField(mx_net_attr, 0, "blob_names",
str_vec_to_mx_strcell(net->blob_names()));
plhs[0] = mx_net_attr;
}
示例3:
EXPORT const char *caffe_net_layer_name(void *netAnon, int i)
{
Net<float> *net = (Net<float> *)netAnon;
return net->layer_names()[i].c_str();
}