您好,登錄后才能下訂單哦!
一個例子:
print("Loading vgg19 weights...") vgg_model = VGG19(include_top=False, weights='imagenet') from_vgg = dict() # 因為模型定義中的layer的名字與原始vgg名字不同,所以需要調整 from_vgg['conv1_1'] = 'block1_conv1' from_vgg['conv1_2'] = 'block1_conv2' from_vgg['conv2_1'] = 'block2_conv1' from_vgg['conv2_2'] = 'block2_conv2' from_vgg['conv3_1'] = 'block3_conv1' from_vgg['conv3_2'] = 'block3_conv2' from_vgg['conv3_3'] = 'block3_conv3' from_vgg['conv3_4'] = 'block3_conv4' from_vgg['conv4_1'] = 'block4_conv1' from_vgg['conv4_2'] = 'block4_conv2' for layer in model.layers: if layer.name in from_vgg: vgg_layer_name = from_vgg[layer.name] layer.set_weights(vgg_model.get_layer(vgg_layer_name).get_weights()) print("Loaded VGG19 layer: " + vgg_layer_name)
densenet.load_weights('model/densenet_weight/densenet_bottom.h6') # densenet.save_weights('densenet_bottom.h6') # print(densenet.weights)# 獲得模型所有權值 t=densenet.get_layer('densenet_conv1/bn') print(t) print(densenet.get_weights()[2])
以上這篇keras獲得某一層或者某層權重的輸出實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。