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