Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
索引张量c++; 我使用C++ API加载一个图(*.PB)。该图已在Python中使用输入图形定义进行了设置和训练:tf.placeholder(tf.float32,[None,84,84,1],name='in'。这应该允许任意批量大小。 启动会话并加载图形后,我获取一个矩形灰度OpenCV Mat图像,将其拆分为较小的方形图像,将其调整为所需的输入大小,并将其存储在向量中: cv::Size smallSize(splitLength, img_in.size().height); std::vector<Mat> input_Images; int y = 0; for (int x = 0; x < img_in.cols; x += smallSize.width) { cv::Rect rect = cv::Rect(x,y, smallSize.width, smallSize.height); cv::Mat temp = cv::Mat(img_in, rect); cv::Size s(height_out, width_out); cv::resize(temp,process_img,s,0,0,cv::INTER_CUBIC); input_Images.push_back(process_img); }_Python_C++_Tensorflow_Tensor - Fatal编程技术网

索引张量c++; 我使用C++ API加载一个图(*.PB)。该图已在Python中使用输入图形定义进行了设置和训练:tf.placeholder(tf.float32,[None,84,84,1],name='in'。这应该允许任意批量大小。 启动会话并加载图形后,我获取一个矩形灰度OpenCV Mat图像,将其拆分为较小的方形图像,将其调整为所需的输入大小,并将其存储在向量中: cv::Size smallSize(splitLength, img_in.size().height); std::vector<Mat> input_Images; int y = 0; for (int x = 0; x < img_in.cols; x += smallSize.width) { cv::Rect rect = cv::Rect(x,y, smallSize.width, smallSize.height); cv::Mat temp = cv::Mat(img_in, rect); cv::Size s(height_out, width_out); cv::resize(temp,process_img,s,0,0,cv::INTER_CUBIC); input_Images.push_back(process_img); }

索引张量c++; 我使用C++ API加载一个图(*.PB)。该图已在Python中使用输入图形定义进行了设置和训练:tf.placeholder(tf.float32,[None,84,84,1],name='in'。这应该允许任意批量大小。 启动会话并加载图形后,我获取一个矩形灰度OpenCV Mat图像,将其拆分为较小的方形图像,将其调整为所需的输入大小,并将其存储在向量中: cv::Size smallSize(splitLength, img_in.size().height); std::vector<Mat> input_Images; int y = 0; for (int x = 0; x < img_in.cols; x += smallSize.width) { cv::Rect rect = cv::Rect(x,y, smallSize.width, smallSize.height); cv::Mat temp = cv::Mat(img_in, rect); cv::Size s(height_out, width_out); cv::resize(temp,process_img,s,0,0,cv::INTER_CUBIC); input_Images.push_back(process_img); },python,c++,tensorflow,tensor,Python,C++,Tensorflow,Tensor,这似乎很好。当我运行std::cout finalOutput[0].DebugString()时,应该像开头一样访问张量。如果输出形状具有秩2,则使用 auto finalOutputTensor = finalOutput[0].tensor<float, 2>(); auto finalOutputTensor=finalOutput[0].tensor(); 及 for(int b=0;b session_create_status = session_deepcyto

这似乎很好。当我运行std::cout finalOutput[0].DebugString()时,应该像开头一样访问张量。如果输出形状具有秩2,则使用

auto finalOutputTensor  = finalOutput[0].tensor<float, 2>();
auto finalOutputTensor=finalOutput[0].tensor();

for(int b=0;b
session_create_status = session_deepcytometry->Run({{ inputLayer, nn_input_tensor}},{outputLayer},{},&finalOutput);
for(int i=0; i<nClasses; i++){
        result.push_back(finalOutput[0].flat<float>()(i));
    }
auto finalOutputTensor  = finalOutput[0].tensor<float, 2>();
for(int b=0; b<BatchSize;b++)
for(int i=0; i<nClasses; i++){
    cout << b << "th output for class "<<i<<" is "<< finalOutputTensor(b, i) <<end; 
}
for(int b=0; b<BatchSize;b++)
for(int i=0; i<nClasses; i++){
    cout << b << "th output for class "<<i<<" is "<< finalOutput[0].flat<float>()(b * nClasses + i) << end; 
}