使用c++; 我尝试用我的训练咖啡网和我的C++数据。我为部署实现了标准caffe示例classification.cpp。在python脚本的训练/测试阶段,net实现了精度=0.93,但现在当我开始部署时,我得到了一些奇怪的结果。我有两门课: 环境 反对

使用c++; 我尝试用我的训练咖啡网和我的C++数据。我为部署实现了标准caffe示例classification.cpp。在python脚本的训练/测试阶段,net实现了精度=0.93,但现在当我开始部署时,我得到了一些奇怪的结果。我有两门课: 环境 反对,c++,machine-learning,neural-network,deep-learning,caffe,C++,Machine Learning,Neural Network,Deep Learning,Caffe,我需要了解目标检测的问题。我相信如果网络在FC层有两个输出(prob1+prob2==1.0f),结果将以Softmaxoutput blob中的两个prob的形式呈现,但结果令人费解。在输出向量中,我得到每个图像的两个相同值。以下是输入和输出层: layer { name: "data" top: "data" type: "Input" input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 }} } l

我需要了解目标检测的问题。我相信如果网络在FC层有两个输出(prob1+prob2==1.0f),结果将以
Softmax
output blob中的两个prob的形式呈现,但结果令人费解。在输出向量中,我得到每个图像的两个相同值。以下是输入和输出层:

layer {
    name: "data"
    top:  "data"
    type: "Input"
    input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 }}
}
layer {
    name: "fc6"
    top:  "fc6"
    type: "InnerProduct"
    bottom: "drop5"
    inner_product_param {
        num_output: 2
        weight_filler {
            type: "xavier"
            std: 0.1
        }
    }
}
layer {
    name: "prob"
    top:  "prob"
    type: "Softmax"
    bottom: "fc6"
}
< P>常规使用的C++代码示例:

Blob<float>* input_layer = m_net->input_blobs()[0];
input_layer->Reshape(1, m_numChannels, m_inputGeometry.height, m_inputGeometry.width);
m_net->Reshape();
std::vector<cv::Mat> input_channels;
Blob<float>* input_layer = m_net->input_blobs()[0];
int width = input_layer->width();
int height = input_layer->height();
float* input_data = input_layer->mutable_cpu_data();

for(int i = 0; i < input_layer->channels(); ++i){
    cv::Mat channel(height, width, CV_32FC1, input_data);
    input_channels->push_back(channel);
    input_data += width * height;
}

cv::split(image_float, *input_channels);
m_net->Forward();
Blob<float>* output_layer = m_net->output_blobs()[0];
const float* begin = output_layer->cpu_data();
const float* end = begin + output_layer->channels();
QVector<float> output = QVector<float>(end - begin, *begin);
Blob*input\u layer=m\u net->input\u Blob()[0];
输入层->重塑(1,m\u numChannels,m\u inputGeometry.height,m\u inputGeometry.width);
m_net->重塑();
std::矢量输入_通道;
Blob*input_layer=m_net->input_blobs()[0];
int width=input_layer->width();
int height=input_layer->height();
浮点*输入\数据=输入\层->可变\ cpu \数据();
对于(int i=0;ichannels();++i){
cv::Mat通道(高度、宽度、cv_32FC1、输入_数据);
输入信道->推回(信道);
输入_数据+=宽度*高度;
}
cv::分割(图像浮动,*输入通道);
m_net->Forward();
Blob*output_layer=m_net->output_blobs()[0];
常量浮点*开始=输出层->cpu_数据();
常量浮点*结束=开始+输出层->通道();
QVector输出=QVector(结束-开始,*开始);

此外,结果与random相似(每个类重复),最小概率值为0.443142。该值通常出现在输出向量中。我做错了什么?

所以,这个问题超出了主题的范围。这是关于STL和Qt向量之间的区别。 原始代码

std::vector<float> output(begin, end);
std::矢量输出(开始、结束);
而不是

QVector<float> output(end - begin, *begin);
QVector输出(结束-开始,*begin);

解决问题。

您的输入数据正确吗?那么为什么只使用完全连接的层呢?卷积层将工作得更好,因为这里我只描述了输入层和输出层。网络也包括卷积层。我认为我的问题不在于准确性。