本文整理汇总了C++中Net::blobs方法的典型用法代码示例。如果您正苦于以下问题:C++ Net::blobs方法的具体用法?C++ Net::blobs怎么用?C++ Net::blobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net
的用法示例。
在下文中一共展示了Net::blobs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blob_set_data_multigpu
//================================================================================================
// Usage: caffe_('blob_set_data_multigpu', BlobIndex, new_data)
//20160215find
static void blob_set_data_multigpu(MEX_ARGS) {
mxCHECK(nrhs == 2 && mxIsUint32(prhs[0]) && mxIsCell(prhs[1]),
"Usage: caffe_('blob_set_data_multigpu', hBlob, new_multi_gpu_data_cell)");
mxCHECK(sync_ptr != NULL,"blob_set_data_multigpu only work on multi-GPU solver");
unsigned int blob_index = *(unsigned int*)(mxGetPr(prhs[0]));
blob_index = blob_index - 1;
//mexPrintf("Real Blob index: %d\n", blob_index);
vector<shared_ptr<P2PSync<float>>>* sync_vec = sync_ptr->get_syncs();
//mexPrintf("blob_set_data_multigpu: Number of syncs: %d\n", sync_vec->size());
if (mxGetNumberOfElements(prhs[1]) != sync_vec->size())
mexErrMsgTxt("blob_set_data_multigpu: input size should be equal to selected gpu number.\n");
// set root solver
const mxArray* const elem = mxGetCell(prhs[1], 0);
mxCHECK(mxIsSingle(elem),"Input data should be single-precision float!!!\n");
Blob<float>* blob = sync_ptr->solver()->net()->blobs()[blob_index].get();
//mexPrintf("Size of data for each sync: %d\nSize of blob: %d\n", mxGetNumberOfElements(elem), blob->count());
//mexPrintf("Blob index: %d\n", blob_index);
mx_mat_to_blob(elem, blob, DATA);
int initial_device;
CUDA_CHECK(cudaGetDevice(&initial_device));
for (int i = 1; i < sync_vec->size(); i++)
{
Solver<float> *solver = (*sync_vec)[i]->solver().get();
Net<float> *net = solver->net().get();
blob = net->blobs()[blob_index].get();
//mexPrintf("sync %d: \tNumber of blobs: %d\n", i, net->blobs().size());
const mxArray* const elem = mxGetCell(prhs[1], i);
mxCHECK(mxIsSingle(elem), "Input data should be single-precision float!!!\n");
//mexPrintf("Size of data for each sync: %d\nSize of blob: %d\n", mxGetNumberOfElements(elem), blob->count());
//mexPrintf("Blob index: %d\n", blob_index);
CUDA_CHECK(cudaSetDevice(solver->param().device_id()));
mx_mat_to_blob(elem, blob, DATA);
CUDA_CHECK(cudaSetDevice(initial_device));
//(*sync_vec)[i]->solver_->net->blobs()[blob_index];
}
}
示例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: caffe_net_blobs_size
EXPORT int caffe_net_blobs_size(void *netAnon)
{
Net<float> *net = (Net<float> *)netAnon;
return net->blobs().size();
}
示例4:
EXPORT void *caffe_net_blob(void *netAnon, int i)
{
Net<float> *net = (Net<float> *)netAnon;
return net->blobs()[i].get();
}