如何在 tensorflowjs 中克隆模型

How to clone a model in tensorflowjs

在一组数据上训练一个模型后,我想得到它的一个副本并在不同的数据集上训练每个副本。有没有办法克隆一个模型,在克隆后每个模型都可以单独训练?

我已经尝试将模型保存在我的本地存储中并从那里生成一个副本,但是 tensorflow 抱怨一些变量名称已经在使用中。

万一其他人感兴趣,我最终解决了它获取我想用 getweights() function, creating a new model with the same architecture and then copying back the other model's weight to it with setweights()

复制的模型的所有权重