我正在尝试使用 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 层仅用于研究吗?