keras获得某一层或者某层权重的输出实例-创新互联

一个例子:

网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了哈密免费建站欢迎大家使用!
    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)

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文名称:keras获得某一层或者某层权重的输出实例-创新互联
地址分享:http://scyanting.com/article/diopoh.html