Repository navigation
Fix sample rate calculation for WeightedRandomSampler and custom samp… - #849
laasyapriya2007 wants to merge 1 commit into
Conversation
|
Hi @laasyapriya2007! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Gentle ping for review when someone has a moment — this corrects the sample-rate computation for |
Types of changes
Motivation and Context / Related issue
Fixes #813.
When
DataLoaderuses samplers wherelen(sampler) != len(dataset)(such asWeightedRandomSampler), computingsample_rate = 1 / len(data_loader)causessample_rateto be computed againstlen(sampler)rather than the full dataset size. This leads to an over-estimatedsample_rateand an explodedexpected_batch_size, burning the privacy budget prematurely.This PR introduces:
_get_batch_sizeand_get_sample_ratehelper functions inopacus/data_loader.pyto derivesample_rate = batch_size / len(dataset)when batch size is available.sample_rateinDPDataLoader.from_data_loader,make_private, andmake_private_with_epsilon.dpdataloader_test.pyandprivacy_engine_test.pyverifying correctsample_rateandexpected_batch_sizewithWeightedRandomSamplerandBatchSampler.How Has This Been Tested
test_from_data_loader_sample_rate_weighted_sampler,test_from_data_loader_custom_sample_rate, andtest_from_data_loader_with_batch_samplerindpdataloader_test.py.test_make_private_with_epsilon_weighted_samplerinprivacy_engine_test.py.Checklist