-
-
Save cosmic-cortex/9281c8a1b4f818c66ed5a10fd6f28fdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Loss(Function): | |
def forward(self, X, Y): | |
""" | |
Computes the loss of x with respect to y. | |
Args: | |
X: numpy.ndarray of shape (n_batch, n_dim). | |
Y: numpy.ndarray of shape (n_batch, n_dim). | |
Returns: | |
loss: numpy.float. | |
""" | |
pass | |
def backward(self): | |
""" | |
Backward pass for the loss function. Since it should be the final layer | |
of an architecture, no input is needed for the backward pass. | |
Returns: | |
gradX: numpy.ndarray of shape (n_batch, n_dim). Local gradient of the loss. | |
""" | |
return self.grad['X'] | |
def local_grad(self, X, Y): | |
""" | |
Local gradient with respect to X at (X, Y). | |
Args: | |
X: numpy.ndarray of shape (n_batch, n_dim). | |
Y: numpy.ndarray of shape (n_batch, n_dim). | |
Returns: | |
gradX: numpy.ndarray of shape (n_batch, n_dim). | |
""" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment