Skip to content

Instantly share code, notes, and snippets.

@cosmic-cortex
Last active September 24, 2019 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmic-cortex/96f3e52c60d8a3391692effece5a12b9 to your computer and use it in GitHub Desktop.
Save cosmic-cortex/96f3e52c60d8a3391692effece5a12b9 to your computer and use it in GitHub Desktop.
class Function:
"""
Abstract model of a differentiable function.
"""
def forward(self, *args, **kwargs):
"""
Forward pass of the function. Calculates the output value and the
gradient at the input as well.
"""
pass
def local_grad(self, *args, **kwargs):
"""
Calculates the local gradients of the function at the given input.
Returns:
grad: dictionary of local gradients.
"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment