Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Matrix Ops #270

Open
maka89 opened this issue Dec 9, 2022 · 0 comments
Open

Custom Matrix Ops #270

maka89 opened this issue Dec 9, 2022 · 0 comments

Comments

@maka89
Copy link

maka89 commented Dec 9, 2022

Hi! Is it possible to write custom operations for autodiff in the reverse mode?

Consider for instance the matrix inverse. Backpropagating through this operation explicitly would create a very long computational graph and be impractical. But you can write a "matrix operation" that does this easily(see below, hope python syntax is ok).

class Inverse:

    def forward(self,X):
        self.inp=X
        self.out=np.linalg.inv(X)
        return self.out
    def backward(self,err):
        return -np.dot(self.out.T,np.dot(err,self.out.T))
@maka89 maka89 changed the title Custom Elementwise Unary Matrix Ops Custom Matrix Ops Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant