我一直在Caffe做一个单一的标签回归问题 . 输入包含5个hdf5文件,我使用不同的图像独立生成这些文件 . 我首先使用单个hdf5文件测试我的网络,并使用大约800个训练图像(批量大小为64)运行10000次迭代 . 最后,当我对相同的训练图像进行预测时,得到的结果如下:
但在测试图像上它是:
据我所知,这是由于训练数据量较少,而且测试数据与训练数据不太相似 .
因此,我尝试将训练数据增加到大约5500个图像,将它们分成5个hdf5文件 . 使用使用14,000次迭代创建的模型对训练数据的预测输出为:
我不明白为什么预测会更糟? caffe如何选择批次? (我的批量大小是64)是否从5个hdf5文件中随机选择批处理?我糟糕的预测背后可能是什么原因?我能做些什么来有效地训练我的模型?我应该添加更多的卷积层吗?任何建议都将极其挽救生命 . 这是我在神经网络和咖啡中的第一次尝试 . 我的网络是:
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"
}
1 回答
尝试添加卷积图层,并删除丢失(如果您遇到过度拟合问题,则可以使用它) . 另外,你必须检查Caffe在训练期间打印的损失;基于此,您可能还需要在求解器文件中更改学习率等 .