【问题标题】:Use trained weight to train different dataset使用经过训练的权重来训练不同的数据集
【发布时间】:2019-10-17 19:24:21
【问题描述】:

我已经在包含 4 个输出类的数据集上训练了一个 CNN 模型,我将模型的权重保存在“weights.h5”中。我想使用这些权重在仅包含 2 个输出类的不同数据集上进行训练,我该怎么做?

【问题讨论】:

  • 你的代码是什么样子的?

标签: tensorflow keras neural-network deep-learning convolution


【解决方案1】:
  1. 加载模型/权重
  2. 从经过训练的网络中删除最后一层
  3. 附加新的输出层
  4. 重新编译
base_model.load_weights(...)

x = base_model.layers[-2].output
x = Dense(2,activation='softmax')(x) # 2 output classes
model = Model(base_model.input,x)

model.compile(...)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-12
    • 2018-07-28
    • 2021-11-01
    • 1970-01-01
    • 2016-04-21
    • 2018-12-26
    • 2020-12-07
    相关资源
    最近更新 更多