Skip to content

Instantly share code, notes, and snippets.

@geoffreyvd
geoffreyvd / STE.py
Last active March 10, 2021 15:51
Straight through estimator for tensforflow/keras 2+
@tf.custom_gradient
def binairy_STE_after_sigmoid(x):
def grad(dy):
return dy
result = tf.round(x)
return result, grad
def model():