xtensor我正在尝试从库中的 blob 数据创建一个数组caffe。使用例如 bymutable_cpu_data()中的函数返回指向数据的指针。这可能吗?如果是,请举个例子。我找到了使用 OpenCV 的示例,但很相似,这使得对矩阵等数据的操作变得更加容易。caffefloat* data = output->mutable_cpu_data();xtensorMatxtensornumpy
你可以这样做,但你需要数据的大小......
请按照下面所说的尝试。
float* data = output->mutable_cpu_data();
//CONVERT YOUR DATA TO FLOAT VECTOR
//I assume the size of your array could be 4.
//Replace 4 with intended size of array.
std::vector<float> fData(data, data+4);
//INITIALIZE XARRAY
xt::xarray<float> a(fData);
Run Code Online (Sandbox Code Playgroud)