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:


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM