我用大量数据训练了一个语音模型(使用 CNTK),并且需要将其适应低资源语言。由于目标语言的数据量太小,我决定使用原始模型的前三层(作为常量)并在顶部附加两个前馈层。我找不到明确的方法来做到这一点。
为了简化事情,假设我的原始模型是:
model1 = Sequential([Recurrence(LSTM(1024, use_peepholes=True)), Dense(40), Recurrence(LSTM(1024, use_peepholes=True)), Dense(256), Dense(num_classes1)])
我需要我的低资源模型是这样的:
model2 = Sequential([Recurrence(LSTM(1024, use_peepholes=True)), Dense(40), Recurrence(LSTM(1024, use_peepholes=True)), Dense(128), Dense(num_classes2)])
如何将 model1 的前三层参数作为常量值复制到 model2(不在 model2 的训练过程中更新)?
最佳答案
您可以克隆网络并卡住参数。该文档可以在这里找到:
https://cntk.ai/pythondocs/graph.html?highlight=clone%20freeze#cntk.ops.functions.CloneMethod
关于python - 将参数复制为常量值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42695910/