当我使用Caffe BP回归模型时,为什么大多数预测结果为0? [英] Why most of the predicted results are 0 when I use a Caffe BP regression model?

查看:365
本文介绍了当我使用Caffe BP回归模型时,为什么大多数预测结果为0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将输入数据转换为hdf5格式. 每个输入数据的形状为309暗和标签 输入数据如下: 部分输入数据是这样的

I converted my input data into hdf5 format. And each input data has a shape of 309 dims and a label the input data just as follow: part of the input data like this

我的净结构如下:

 name: "RegressionNet"
layer {
    name: "framert"
    type: "HDF5Data"
    top: "data"
    top: "label"
    include {
        phase: TRAIN
    }
    hdf5_data_param {
        source: "train_data_list.txt"
        batch_size: 100
    }
}
layer {
    name: "framert"
    type: "HDF5Data"
    top: "data"
    top: "label"
    include {
        phase: TEST
    }
    hdf5_data_param {
        source: "test_data_list.txt"
        batch_size: 100
    }
}
layer {
    name: "inner1"
    type: "InnerProduct"
    bottom: "data"
    top: "inner1"
    param {
        lr_mult: 1
        decay_mult: 1.5
    }
    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: "inner2"
    type: "InnerProduct"
    bottom: "inner1"
    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: "inner3"
    type: "InnerProduct"
    bottom: "inner2"
    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: "inner4"
    type: "InnerProduct"
    bottom: "inner3"
    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: "inner5"
    type: "InnerProduct"
    bottom: "inner4"
    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: "inner6"
    type: "InnerProduct"
    bottom: "inner5"
    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
        }
    }
}
layer {
    name: "relu1"
    type: "ReLU"
    bottom: "inner6"
    top: "inner6"
    relu_param {
        engine: CAFFE
    }
}
layer {
    name: "accuracy"
    type: "Accuracy"
    bottom: "inner6"
    bottom: "label"
    top: "accuracy"
    include {
        phase: TEST
    }
}
layer {
    name: "loss"
    type: "EuclideanLoss"
    bottom: "inner6"
    bottom: "label"
    top: "loss"
}

我的求解器如下:

net: "net_csv_hdf5.prototxt"

test_iter: 100

test_interval: 100

base_lr: 0.001

momentum: 0.9

weight_decay: 0.0005

lr_policy: "inv"

gamma: 0.0001

power: 0.75

display: 50

max_iter: 5000

snapshot: 2500

snapshot_prefix: "/examples"

solver_mode: CPU

完成训练阶段后,我使用测试数据进行预测,而预测结果如下(零点太多):

After completing the training phase,I use the test data to predict, while the predicted result as follow(there are too many zeros):

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.000122316
0.00318826
0.00606083
0.0092759
0.0124592
0.015264
0.0181027
0.021088
0.0237832
0.027108
0.0306765
0.0345342
0.0379068
0.0409781
0.044281
0.0478444
0.0509017

推荐答案

您忘了像这样在net.prototxt中添加激活功能"

You forget add activation function in net.prototxt like this"

layer {
   name: "Sigmoid1"
   type: "Sigmoid"
   bottom: "inner1"
   top: "Sigmoid1"
 }

这篇关于当我使用Caffe BP回归模型时,为什么大多数预测结果为0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆