问题描述
我使用了tensorflow对象检测API。
这是我的环境。
所有图像均来自可可API
Tensorflow version : 1.13.1
Tensorboard version : 1.13.1
Number of test images : 3000
Number of train images : 24000
Pre-trained model : SSD mobilenet v2 quantized 300x300 coco
Number of detecting class : 1(person)
这是我的train_config。
train_config: {
batch_size: 6
optimizer {
adam_optimizer: {
learning_rate {
exponential_decay_learning_rate: {
initial_learning_rate:0.000035
decay_steps: 7
decay_factor: 0.98
}
}
}
}
fine_tune_checkpoint: "D:/TF/models/research/object_detection/ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03/model.ckpt"
fine_tune_checkpoint_type: "detection"
num_steps: 200000
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
ssd_random_crop {
}
}
}
我找不到最佳的学习速度,合适的衰减步骤和因子。
所以我做了很多培训,但是the result总是很相似。
我该如何解决?
我已经花了一个星期的时间来解决这个问题。
在另一篇文章中,有人建议对数据集(图像)添加干扰。
但我不知道这是什么意思。
我该如何实现?
解决方法
我认为在另一篇文章中提到的是通过向您的训练数据集中添加一些嘈杂的图像来进行一些数据增强。这意味着您将一些随机变换应用于输入,以便该模型旨在更好地泛化。 可以使用的一种噪声是随机高斯噪声(https://en.wikipedia.org/wiki/Gaussian_noise),它是由对象检测API中的补丁程序施加的。 尽管您似乎有足够的训练图像,但值得一试。 噪音看起来像:
...
data_augmentation_options {
random_horizontal_flip {
}
}
data_augmentation_options {
ssd_random_crop {
}
}
data_augmentation_options {
randompatchgaussian {
// The patch size will be chosen to be in the range
// [min_patch_size,max_patch_size).
min_patch_size: 300;
max_patch_size: 300; //if you want the whole image to be noisy
}
}
...
有关数据扩充的列表,您可以检查: https://github.com/tensorflow/models/blob/master/research/object_detection/protos/preprocessor.proto
关于学习率,一种常见的策略是尝试较高的学习率(例如0.02),另一种则是已经尝试过的很小的学习率。我建议您尝试使用0.02,将其放置一会儿,或者使用指数衰减学习率来查看结果是否更好。
更改batch_size也可以带来一些好处,请尝试batch_size = 2而不是6。
我还建议您离开培训以获取更多步骤,直到您看不到培训上的任何改进为止,或者直到您在配置中定义了200000步骤之后再离开培训。
一些更深层次的策略可以帮助模型更好地运行,对此,他们已经回答了:https://stackoverflow.com/a/61699696/14203615
话虽如此,如果正确地制作了数据集,您应该在测试集上获得良好的结果。