是否可以修正tfpl.IndependentNormal中的平均值/var参数?

2024-05-16 09:56:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Python编写了一个标准的概率神经网络,最后一层是tfp.layers.IndependentNormal,这给了我一个正态分布。然而,我只想训练上述分布的平均值,保持方差不变

有没有人尝试过类似的方法,或者知道如何做到这一点


Tags: 方法标准layers神经网络概率平均值tfp方差
1条回答
网友
1楼 · 发布于 2024-05-16 09:56:36

您可以这样做:

model = Sequential([
    ...
    tfpl.DistributionLambda(lambda t: tfd.Independent(tfd.Normal(loc = t, scale = 0.5)))
])

在这里,您需要将scale设置为一个常量值以保持固定

相关问题 更多 >