pytorch/opacus

Can opacus only inject differential noise in only one layer of parameters or some target layers?

hacker-jerry opened this issue · 2 comments

Hi, I noticed that Opacus is on the whole model to be performed differential privacy,whether can only on a layer parameter performed differential privacy(density gradient,adding noise)in training.

For example, consider a DNN classifier where I want to achieve differential privacy only for the classifier layer, and therefore only CLIP the parameters of that layer, and also only inject noise into that layer. How should this be done?

Thanks!

You can apply DP optimizer to the desired part of model and apply a non-private optimizer to the remaining.
For example, after you privatize the mode by the privacy engine, only apply the private optimizer to the parameters in the classification layer and create another non-private optimizer which applied to the other model parameters.

Close the task due to no response.