如何解决如何使用 DenseVariational 层保存模型?
我正在尝试使用 DenseVariational 层构建模型,以便它可以报告认知不确定性。类似于 https://www.tensorflow.org/probability/examples/Probabilistic_Layers_Regression#figure_3_epistemic_uncertainty
模型训练效果很好,现在我想保存模型并将其加载到生产环境中。但是,当我尝试 model.save('path/model.h5')
时,我得到了
Layer DenseVariational has arguments in `__init__` and therefore must override `get_config`.
然后我加了
class CustomVariational(tfp.layers.DenseVariational):
def get_config(self):
config = super().get_config().copy()
config.update({
'units': self.units,'make_posterior_fn': self._make_posterior_fn,'make_prior_fn': self._make_prior_fn
})
return config
但它因新错误而失败
Unable to create link (name already exists)
DenseVariational 层仅用于研究吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。