【问题标题】:How to add layers to a sequential model from an existing model?如何从现有模型向顺序模型添加层?
【发布时间】:2019-09-08 06:12:13
【问题描述】:

我使用 VGG16 作为我的基础 CNN 模型:

base_model = VGG16(weights='imagenet', include_top=False, input_shape=(64,64,3) )

我想新建一个模型,把VGG16的层一层一层添加到我的模型中,再添加自己的层。

我知道如何使用 model.add() 命令手动添加新闻层,但我不确定如何遍历我的基本模型层并将它们添加到我的模型中

【问题讨论】:

    标签: python python-3.x keras


    【解决方案1】:

    我找到了问题的答案。

    bn = []
    for layer in base_model.layers:
        bn.append(layer)
    model = Sequential(bn)
    model.summary()
    

    【讨论】:

      猜你喜欢
      • 2017-06-13
      • 2019-10-28
      • 2011-05-19
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 2021-02-17
      • 2010-10-24
      • 1970-01-01
      相关资源
      最近更新 更多