张量流中的可微圆函数?

2024-05-14 04:31:04 发布

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

所以我的网络输出是一个概率列表,然后我用它来取整tf.圆形()为0或1,这对于此项目至关重要。 后来我发现了tf.圆形是不可微的,所以我有点迷路了。。:/


Tags: 项目网络列表tf圆形概率迷路
3条回答

你可以用事实tf.最大值()和tf.最小值()是可微的,输入是从0到1的概率

# round numbers less than 0.5 to zero;
# by making them negative and taking the maximum with 0
differentiable_round = tf.maximum(x-0.499,0)
# scale the remaining numbers (0 to 0.5) to greater than 1
# the other half (zeros) is not affected by multiplication
differentiable_round = differentiable_round * 10000
# take the minimum with 1
differentiable_round = tf.minimum(differentiable_round, 1)

示例:

^{pr2}$

是沿着x-sin(2pix)/(2pi)这条线的东西吗?在

我肯定有办法把斜坡压得更陡一点。在

enter image description here

舍入是一个基本上不可微的函数,所以你在这方面运气不好。对于这种情况,通常的方法是找到一种方法,要么使用概率来计算期望值,要么采用输出的最大概率选择一个作为网络的预测。如果你不使用输出来计算你的损失函数,你可以继续把它应用到结果中,它是否可微也无所谓。现在,如果你想要一个信息损失函数来训练网络,也许你应该考虑一下,将输出保持在概率的形式是否对你有利(这可能会使你的培训过程更顺畅)——这样你就可以在培训后,将概率转换为网络之外的实际估计值。在

相关问题 更多 >