Tensorflow中的可微圆函数? [英] Differentiable round function in Tensorflow?

查看:24
本文介绍了Tensorflow中的可微圆函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的网络的输出是一个概率列表,然后我使用 tf.round() 将其舍入为 0 或 1,这对这个项目至关重要.然后我发现 tf.round 是不可微的,所以我有点迷失在那里.. :/

So the output of my network is a list of propabilities, which I then round using tf.round() to be either 0 or 1, this is crucial for this project. I then found out that tf.round isn't differentiable so I'm kinda lost there.. :/

推荐答案

四舍五入是一个根本上不可微的函数,所以你在那里不走运.这种情况的正常程序是找到一种方法来使用概率,例如通过使用它们来计算期望值,或者通过获取输出的最大概率并选择该概率作为网络的预测.但是,如果您不使用输出来计算损失函数,则可以继续将其应用于结果,并且它是否可微无关紧要.现在,如果您想要一个用于训练网络的信息损失函数,也许您应该考虑将输出保持为概率格式是否实际上对您有利(这可能会使您的训练过程更顺畅)-那样您可以在训练后将概率转换为网络外部的实际估计.

Rounding is a fundamentally nondifferentiable function, so you're out of luck there. The normal procedure for this kind of situation is to find a way to either use the probabilities, say by using them to calculate an expected value, or by taking the maximum probability that is output and choose that one as the network's prediction. If you aren't using the output for calculating your loss function though, you can go ahead and just apply it to the result and it doesn't matter if it's differentiable. Now, if you want an informative loss function for the purpose of training the network, maybe you should consider whether keeping the output in the format of probabilities might actually be to your advantage (it will likely make your training process smoother)- that way you can just convert the probabilities to actual estimates outside of the network, after training.

这篇关于Tensorflow中的可微圆函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆