Skip to content

Commit

Permalink
Add helper functions to core.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 321609820
  • Loading branch information
jesseengel authored and Magenta Team committed Jul 16, 2020
1 parent dd3fb52 commit 7afc8f0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ddsp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def soft_limit(x, x_min=0.0, x_max=1.0):
return tf.nn.softplus(x) + x_min - tf.nn.softplus(x - (x_max - x_min))


def gradient_reversal(x):
"""Identity operation that reverses the gradient."""
return tf.stop_gradient(2.0 * x) - x


# Unit Conversions -------------------------------------------------------------
def midi_to_hz(notes: Number) -> Number:
"""TF-compatible midi_to_hz function."""
Expand Down

0 comments on commit 7afc8f0

Please sign in to comment.