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

Question about backprop #54

Open
yousifKashef opened this issue Aug 15, 2023 · 5 comments
Open

Question about backprop #54

yousifKashef opened this issue Aug 15, 2023 · 5 comments

Comments

@yousifKashef
Copy link

Hi Matt,

is it possible to get the gradient from back propagation using core ml or metal? I am trying to implement an adversarial attack on a core ML resnet 50 and don't know how to go about it?

by the way, the tutorials you post are excellent

@hollance
Copy link
Owner

Core ML: no, gradients are not exposed in the API.

Metal: yes, but you'll have to re-implement the model using the lowest-level MPS primitives, such as MPSCNNConvolutionGradient.

@yousifKashef
Copy link
Author

yousifKashef commented Aug 15, 2023 via email

@hollance
Copy link
Owner

It's possible a nicer API is available these days (I haven't used MPS in a while) but in the past you had to implement both the forward and backward pass yourself. So a very simple model would be MPSLinearLayer -> MPSLossFunction -> MPSLinearLayerGradient where the MPSLinearLayerGradient is the backward pass.

@yousifKashef
Copy link
Author

yousifKashef commented Aug 16, 2023 via email

@hollance
Copy link
Owner

I don't have any examples for this, unfortunately.

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

2 participants