Tensorflow 之finetune微调模型方法&&不同层上设置不同的学习率

ConvNets:

AlexNet finetune:

– 自己搭建的网络,加载初始化模型:

def load_with_skip(data_path, session, skip_layer):
    data_dict = np.load(data_path).item()
    for key in data_dict:
        if key not in skip_layer:
            with tf.variable_scope(key, reuse=True):
                for subkey, data in zip(('weights', 'biases'), data_dict[key]):
                    session.run(tf.get_variable(subkey).assign(data))

print('Load pre-trained model: {}'.format(weight_file))
load_with_skip(weight_file, sess, ['fc8']) # Skip weights from fc8

VGG模型finetune:

– 自定义网络;加载参数,很详细教程:

– 另外:这是个基于tensorflow-vgg16Caffe to TensorFlow的VGG16和VGG19的一个TensorFlow的实现。

ResNet的slim模型finetune:

    原文作者:tensorflow
    原文地址: https://www.cnblogs.com/ranjiewen/p/10231170.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞