我使用下面的代码来调用训练有素的caffemodel来预测值。不幸的是,当我改变Factors的数据时,结果没有变化。有人可以帮助我
std::string ModelFilePath = "net_csv_hdf5_for_prediction.prototxt";
std::string WeightFilePath = "rt_hdf5_iter_5000.caffemodel";
float Factors[] = { -0.007, 0.207, -0.071, -0.007, -0.009, ...}; // here I ignore other 304 data
std::vector<float> Descriptors(Factors, Factors + sizeof(Factors) / sizeof(float));
CPredictedTest PredictedTest(ModelFilePath, WeightFilePath, 1);
std::vector<float> Results = PredictedTest.predict(Descriptors);
这是我的网络模型文本 - net_csv_hdf5_for_prediction.prototxt:
name: "CSVNet"
layer {
name: "framert"
type: "Input"
top: "data"
input_param {
shape {
dim: 1 dim: 1 dim: 1 dim: 309
}
}
}
layer {
name: "inner1"
type: "InnerProduct"
bottom: "data"
top: "inner1"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "sigmoid1"
type: "Sigmoid"
bottom: "inner1"
top: "sigmoid1"
}
layer {
name: "inner2"
type: "InnerProduct"
bottom: "sigmoid1"
top: "inner2"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 400
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "sigmoid2"
type: "Sigmoid"
bottom: "inner2"
top: "sigmoid2"
}
layer {
name: "inner3"
type: "InnerProduct"
bottom: "sigmoid2"
top: "inner3"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 300
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "sigmoid3"
type: "Sigmoid"
bottom: "inner3"
top: "sigmoid3"
}
layer {
name: "inner4"
type: "InnerProduct"
bottom: "sigmoid3"
top: "inner4"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 200
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "sigmoid4"
type: "Sigmoid"
bottom: "inner4"
top: "sigmoid4"
}
layer {
name: "inner5"
type: "InnerProduct"
bottom: "sigmoid4"
top: "inner5"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 100
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "sigmoid5"
type: "Sigmoid"
bottom: "inner5"
top: "sigmoid5"
}
layer {
name: "inner6"
type: "InnerProduct"
bottom: "sigmoid5"
top: "inner6"
param {
lr_mult: 1
decay_mult: 1.0
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
答案 0 :(得分:0)
训练模型时可能会发生错误。你用什么作为输入?你训练了几个例子?产出在哪里?如何通过培训提高准确性和损失?你的损失函数是什么?
顺便说一下,尺寸的尺寸太大。您的输入大小只有309.网络中blob的大小不应该比这大。