gpt4 book ai didi

machine-learning - Caffe 中的回归 : Prediction is highly erroneous

转载 作者:行者123 更新时间:2023-11-30 09:10:38 24 4
gpt4 key购买 nike

我一直在 Caffe 中解决单标签回归问题。输入包含 5 个 hdf5 文件,这些文件是我使用不同图像独立生成的。我首先使用单个 hdf5 文件测试我的网络,并使用大约 800 个训练图像(批量大小 64)运行 10000 次迭代。最后,当我对相同的训练图像进行预测时,得到的结果如下:

enter image description here

但在测试图像上是:

enter image description here

据我了解,这是由于训练数据量较少,并且测试数据与训练数据不太相似。

因此,我尝试将训练数据增加到大约 5500 张图像,并将它们分成 5 个 hdf5 文件。使用经过 14,000 次迭代创建的模型对训练数据进行的预测输出为:

enter image description here

我不明白为什么预测会更糟糕? caffe如何选择批处理? (我的批处理大小是 64)它是否从 5 个 hdf5 文件中随机选择一个批处理?我的错误预测背后的原因可能是什么?我该如何有效地训练我的模型?我应该添加更多的卷积层吗?任何建议都将极大地挽救生命。这是我在神经网络和caffe方面的第一次尝试。我的网络是:

name: "Regression"
layer{
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
hdf5_data_param {
source: "train_hdf5file.txt"
batch_size: 64
shuffle: true
}
include: { phase: TRAIN }
}
layer{
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
hdf5_data_param {
source: "test_hdf5file.txt"
batch_size: 30
}
include: { phase: TEST }
}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param { lr_mult: 1 }
param { lr_mult: 2 }
convolution_param {
num_output: 20
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "dropout1"
type: "Dropout"
bottom: "pool1"
top: "pool1"
dropout_param {
dropout_ratio: 0.1
}
}

layer{
name: "fc1"
type: "InnerProduct"
bottom: "pool1"
top: "fc1"
param { lr_mult: 1 decay_mult: 1 }
param { lr_mult: 2 decay_mult: 0 }
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "dropout2"
type: "Dropout"
bottom: "fc1"
top: "fc1"
dropout_param {
dropout_ratio: 0.5
}
}
layer{
name: "fc2"
type: "InnerProduct"
bottom: "fc1"
top: "fc2"
param { lr_mult: 1 decay_mult: 1 }
param { lr_mult: 2 decay_mult: 0 }
inner_product_param {
num_output: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer{
name: "loss"
type: "EuclideanLoss"
bottom: "fc2"
bottom: "label"
top: "loss"
}

最佳答案

尝试添加卷积层,并删除 dropout(如果遇到过度拟合问题,则可以使用它)。此外,您还必须检查 Caffe 在训练期间打印的损失;基于此,您可能还需要更改解算器文件中的学习率等。

关于machine-learning - Caffe 中的回归 : Prediction is highly erroneous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39920977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com