Differentiable round function in Tensorflow?

前端 未结 6 1065
面向向阳花
面向向阳花 2021-02-04 20:27

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.roun

6条回答
  •  爱一瞬间的悲伤
    2021-02-04 20:57

    In range 0 1, translating and scaling a sigmoid can be a solution:

      slope = 1000
      center = 0.5
      e = tf.exp(slope*(x-center))
      round_diff = e/(e+1)
    

提交回复
热议问题