How to adjusting the noise increase parameter for each round

jeff20210616: <p>privacy_engine = PrivacyEngine(centralized_model,<br>
batch_size=256,<br>
sample_size=50000,<br>
alphas=range(2,32),<br>
noise_multiplier=1.3,<br>
max_grad_norm=1.0,)<br>
privacy_engine.attach(centralized_optimizer)</p>
<p>The current noise increase parameter is bound to the optimizer, which means that each gradient descent can only use the same coefficient, and if I want to automatically change the noise coefficient, how can I make the gradient descent, and how to get the current privacy budget</p>

ashkan_software: <p>Hi <a class="mention" href="/u/jeff20210616">@jeff20210616</a>,</p>
<p>Thank you for using Opacus!</p>
<p>I believe the question is, how can you dynamically change the noise parameter and how to get the current privacy budget accordingly. If so, Opacus certainly supports that!</p>
<p>New Opacus (any version &gt; 1.0) supports dynamic privacy parameters. This is handled by <code>scheduler</code>: (See “Dynamic Privacy Parameters” in <a href="https://github.com/pytorch/opacus/releases/tag/v1.0.0" rel="noopener nofollow ugc">https://github.com/pytorch/opacus/releases/tag/v1.0.0</a>)</p>
<p>I also realized that you are using the old Opacus (e.g. you have the method <code>privacy_engine.attach()</code>). To take advantage of dynamic privacy and other useful features of Opacus, please use the newest Opacus version <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:"> <a href="https://github.com/pytorch/opacus/blob/main/Migration_Guide.md" rel="noopener nofollow ugc">https://github.com/pytorch/opacus/blob/main/Migration_Guide.md</a></p>

jeff20210616: <p>OK,thank you very much</p>

jeff20210616: <p>I have a other question, I read the pepar and the code, I find the default cropping norm is 1 where sensitivity is 1 , and if I crop norm is not 1 ,how can I call use privacy analysis interface?</p>

ashkan_software: <p>Hi,</p>
<p>You can use any clipping value and noise value that you would like. Once you define your noise value and clipping value, you can call</p>
<p><code>eps = privacy_engine.get_epsilon(delta=target_delta)</code></p>
<p>to get the privacy budget.</p>

jeff20210616: <p>I mean in your code library , I find some problem there<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/2/22f2a431f0b208760ff2e993989b877195a94efc.png" data-download-href="https://discuss.pytorch.org/uploads/default/22f2a431f0b208760ff2e993989b877195a94efc" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/2/22f2a431f0b208760ff2e993989b877195a94efc.png" alt="image" data-base62-sha1="4Za5CUTrJC5jTwweakKwiiWaucc" width="634" height="500" data-dominant-color="FCFBFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1116×880 30.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

jeff20210616: <p>just like this:<br>
<img src="https://discuss.pytorch.org/uploads/default/original/3X/d/f/dffec19a38ad6c0471ee2d1aabbee9bf96ca4c1c.png" alt="image" data-base62-sha1="vXyhTGfc82sb61JSkqBWRc9CM9e" width="513" height="351"></p>

alexandresablayrolle: <p>In the analysis, it is assumed that the gradient has normed bounded by 1 and the noise is of std sigma (per coordinate). The key thing is that if we multiply the gradient bound by C, we also multiply the noise by C: the noise we add has in effect a standard deviation of sigma * C.</p>
<p>See opacus/optimizers/optimizer.py:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/4/44278d6c090b5574cca34fc48e2b079caf208013.png" data-download-href="https://discuss.pytorch.org/uploads/default/44278d6c090b5574cca34fc48e2b079caf208013" title="Screenshot 2022-02-11 at 15.19.29"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44278d6c090b5574cca34fc48e2b079caf208013_2_690x288.png" alt="Screenshot 2022-02-11 at 15.19.29" data-base62-sha1="9IVcWao9lFi7SpyPZ6fDzPZKDxV" width="690" height="288" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44278d6c090b5574cca34fc48e2b079caf208013_2_690x288.png, https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44278d6c090b5574cca34fc48e2b079caf208013_2_1035x432.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44278d6c090b5574cca34fc48e2b079caf208013_2_1380x576.png 2x" data-dominant-color="F9FAFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2022-02-11 at 15.19.29</span><span class="informations">1672×698 64.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

jeff20210616: <p>in fact , my question is not about the STD. I know the sigma include the sensitivity . I think what you consider is the distribution of neighboring datasets with sensitivity 1 :</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/b/8be7ea29a20c92e5b6d5d77851e05d5084a670f8.png" data-download-href="https://discuss.pytorch.org/uploads/default/8be7ea29a20c92e5b6d5d77851e05d5084a670f8" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/8/b/8be7ea29a20c92e5b6d5d77851e05d5084a670f8.png" alt="image" data-base62-sha1="jXFf5oVOiAjOF196P0l0aCi5n3G" width="568" height="499" data-dominant-color="FCFBFC"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">792×696 18.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>You can compare the theorem below</p>

jeff20210616: <p>you can see that. if this function have the sensitivity is u. there is a parameter u in the proposition. it’is not about the sigma. and if the sensitivity is 1. we can write : a/2*sigma**2.but if is not 1,just like this:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/f/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b.png" data-download-href="https://discuss.pytorch.org/uploads/default/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/f/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b_2_601x500.png" alt="image" data-base62-sha1="fXQzddGbz20CJMjQr7Ki1b4wf8v" width="601" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/f/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b_2_601x500.png, https://discuss.pytorch.org/uploads/default/original/3X/6/f/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/6/f/6fe4812a09bd3cc1464d4374d48cd8709cd8c06b.png 2x" data-dominant-color="F7F6F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">646×537 56.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

jeff20210616: <p>and I think there is only one explanation, that the sigma in your code doesn t contain the sensitivity and the sensitivity has been offset.That is, the calculation of the RDP is independent of the sensitivity</p>

jeff20210616: <p>and I noticed that here may be loss the coefficient ： 1/(aplha-1)<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/2/524ccf5e0ad5509386ee527a06c46538ba7a097e.png" data-download-href="https://discuss.pytorch.org/uploads/default/524ccf5e0ad5509386ee527a06c46538ba7a097e" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/5/2/524ccf5e0ad5509386ee527a06c46538ba7a097e.png" alt="image" data-base62-sha1="bK3ItjIKqm2OKEaz2z831FqRC1g" width="583" height="500" data-dominant-color="FBFAFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">665×570 15.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

alexandresablayrolle: <p>Exactly. Both the gradient and the noise are multiplied by C. So if you look at (gradient / C), then this function has sensitivity 1 and thus you can deduce all the properties that you mentioned.</p>

alexandresablayrolle: <p>The reason here is that the two branches (q=1 and q!=1) have different ways of computing the divergence. See Section 3 of <a href="https://arxiv.org/pdf/1908.10530.pdf" rel="noopener nofollow ugc">https://arxiv.org/pdf/1908.10530.pdf</a> (where log_a is divided by alpha - 1)</p>

jeff20210616: <p>is not this?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea4b084f99b98103354cf562f2ed7b275278852f.png" data-download-href="https://discuss.pytorch.org/uploads/default/ea4b084f99b98103354cf562f2ed7b275278852f" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/ea4b084f99b98103354cf562f2ed7b275278852f_2_690x129.png" alt="image" data-base62-sha1="xqEu21RQbAeT1lUjNn0lKtXAtMH" width="690" height="129" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/ea4b084f99b98103354cf562f2ed7b275278852f_2_690x129.png, https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea4b084f99b98103354cf562f2ed7b275278852f.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/a/ea4b084f99b98103354cf562f2ed7b275278852f.png 2x" data-dominant-color="F2F0F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">880×165 59.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

karthikprasad: <p>Hi <a class="mention" href="/u/jeff20210616">@jeff20210616</a> , I’m not sure I follow your question. Is that not what?</p>

jeff20210616: <p>yes,thank you. I mean  whatever q=1 or  q!=1, the equation of RDP has this coefficient:1/(alpha-1).Maybe I have some problems with my understanding.</p>

karthikprasad: <p>I’m sensing  the confusion is due to the notations.</p>
<ul>
<li>In Definition 1 of <a href="https://arxiv.org/pdf/1908.10530.pdf" rel="noopener nofollow ugc">https://arxiv.org/pdf/1908.10530.pdf</a>, q is the probability density function.</li>
<li>In the code with two branches (q=1 and q!=1), q is the sampling rate.</li>
</ul>
<p>Ofcourse, the 1/(alpha-1) term does appear in the Rényi Divergence formula. However, when q=1 (i.e., when sampling ratio is 1), there is essentially no sampling. The RDP of a Gaussian Mechanism is derived to be equal to alpha/(2 * sigma^2) as written in the code (see proposition 7 of <a href="https://arxiv.org/pdf/1702.07476.pdf" rel="noopener nofollow ugc">https://arxiv.org/pdf/1702.07476.pdf</a>)</p>

jeff20210616: <p>OK, I get it . thank you very much</p>

jeff20210616: <p>I get  it . thank you very much.<br>
I have last question: Is the data sampled here with any put back(replace=true) or no put back(replace=flase)?</p>