GoogLeNet模型的微调 [英] Fine Tuning of GoogLeNet Model

查看:1510
本文介绍了GoogLeNet模型的微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从头开始训练GoogLeNet模型。但它没有给我有希望的结果。

作为一种替代,我想对我的数据集上的GoogLeNet模型进行微调。有谁知道我应该采取的步骤是什么?

I trained GoogLeNet model from scratch. But it didn't give me the promising results.
As an alternative, I would like to do fine tuning of GoogLeNet model on my dataset. Does anyone know what are the steps should I follow?

推荐答案

假设您尝试进行图片分类。这些应该是调整模型的步骤:

Assuming you are trying to do image classification. These should be the steps for finetuning a model:

原始的分类层loss3 / classifier 输出1000个类的预测(它 mum_output 设置为1000)。您需要将其替换为带有适当 num_output 的新图层。替换分类图层:

The original classification layer "loss3/classifier" outputs predictions for 1000 classes (it's mum_output is set to 1000). You'll need to replace it with a new layer with appropriate num_output. Replacing the classification layer:


  1. 更改图层的名称(以便在从caffemodel文件中读取原始权重时,的层)。

  2. num_output 更改为要尝试预测的正确输出类数。

  3. 请注意,您需要更改所有分类图层。通常只有一个,但GoogLeNet恰好有三个: loss1 / classifier loss2 / classifier loss3 / classifier

  1. Change layer's name (so that when you read the original weights from caffemodel file there will be no conflict with the weights of this layer).
  2. Change num_output to the right number of output classes you are trying to predict.
  3. Note that you need to change ALL classification layers. Usually there is only one, but GoogLeNet happens to have three: "loss1/classifier", "loss2/classifier" and "loss3/classifier".



2 。数据



您需要使用要微调的新标签创建一个新的训练数据集。有关如何创建lmdb数据集的信息,请参见此帖

调整模型时,您可以训练所有模型的权重,或者选择修正一些权重(通常是较低/较深层的过滤器)只训练最顶层的权重。这个选择取决于你,它通常取决于可用的训练数据的数量(更多的例子你有更多的权重,你可以承担的微调)。

每个层(拥有可训练参数)有 param {lr_mult:XX} 。该系数确定这些权重对SGD更新的敏感程度。设置 param {lr_mult:0} 表示您固定此图层的权重,并且在培训过程中不会更改。

编辑您的 train_val.prototxt

When finetuning a model, you can train ALL model's weights or choose to fix some weights (usually filters of the lower/deeper layers) and train only the weights of the top-most layers. This choice is up to you and it ususally depends on the amount of training data available (the more examples you have the more weights you can afford to finetune).
Each layer (that holds trainable parameters) has param { lr_mult: XX }. This coefficient determines how susceptible these weights to SGD updates. Setting param { lr_mult: 0 } means you FIX the weights of this layer and they will not be changed during the training process.
Edit your train_val.prototxt accordingly.

运行 caffe train ,但提供caffemodel权重作为初始权重:

Run caffe train but supply it with caffemodel weights as an initial weights:

~$ $CAFFE_ROOT/build/tools/caffe train -solver /path/to/solver.ptototxt -weights /path/to/orig_googlenet_weights.caffemodel 

这篇关于GoogLeNet模型的微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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