def get_args(): parser = argparse.ArgumentParser() # BASICS parser.add_argument('--seed', type=int, default=None, help='sets random seed') parser.add_argument('--log-interval', type=int, default=100, help='print updates after n steps') parser.add_argument('--base-log-dir', type=str, default='logs/gen/', help='path where logs for all runs are stored') parser.add_argument('--log-name', type=str, default=None, help='subdirectory for this run') parser.add_argument('--log-dir', type=str, default=None, help='override save path. constructed if None') parser.add_argument('--data', type=str, default='digits', help='options are digits, fashion and 2d') parser.add_argument('--create-dataset', action='store_true', default=True, help='if true, make 60k synthetic code_balanced') # OPTIMIZATION parser.add_argument('--batch-size', '-bs', type=int, default=500) parser.add_argument('--test-batch-size', '-tbs', type=int, default=1000) parser.add_argument('--gen-batch-size', '-gbs', type=int, default=1000) parser.add_argument('--epochs', '-ep', type=int, default=5) parser.add_argument('--lr', '-lr', type=float, default=0.01, help='learning rate') parser.add_argument('--lr-decay', type=float, default=0.9, help='per epoch learning rate decay factor') # MODEL DEFINITION # parser.add_argument('--batch-norm', action='store_true', default=True, help='use batch norm in model') parser.add_argument('--conv-gen', action='store_true', default=True, help='use convolutional generator') parser.add_argument('--d-code', '-dcode', type=int, default=5, help='random code dimensionality') parser.add_argument('--gen-spec', type=str, default='200', help='specifies hidden layers of generator') parser.add_argument('--kernel-sizes', '-ks', type=str, default='5,5', help='specifies conv gen kernel sizes') parser.add_argument('--n-channels', '-nc', type=str, default='16,8', help='specifies conv gen kernel sizes') # DP SPEC parser.add_argument('--d-rff', type=int, default=1000, help='number of random filters for apprixmate mmd') parser.add_argument('--rff-sigma', '-rffsig', type=str, default=None, help='standard dev. for filter sampling') parser.add_argument('--noise-factor', '-noise', type=float, default=5.0, help='privacy noise parameter') # ALTERNATE MODES parser.add_argument('--single-release', action='store_true', default=True, help='get 1 data mean embedding only') parser.add_argument('--loss-type', type=str, default='rff', help='how to approx mmd', choices=['rff', 'kmeans', 'real_mmd']) # parser.add_argument('--real-mmd', action='store_true', default=False, help='for debug: dont approximate mmd') # parser.add_argument('--kmeans-mmd', action='store_true', default=False, help='for debug: dont approximate mmd') parser.add_argument('--n-means', type=int, default=10, help='number of means to find per class') parser.add_argument('--dp-kmeans-encoding-dim', type=int, default=10, help='dimension the data is projected to') parser.add_argument('--tgt-epsilon', type=float, default=1.0, help='privacy epsilon for dp k-means') parser.add_argument('--kmeans-delta', type=float, default=0.01, help='soft failure probability in dp k-means') parser.add_argument('--mmd-type', type=str, default='sphere', help='how to approx mmd', choices=['sphere', 'r+r']) parser.add_argument('--center-data', action='store_true', default=False, help='k-means requires centering') # synth_d2 data parser.add_argument('--synth-spec-string', type=str, default='disc_k5_n10000_row5_col5_noise0.2', help='') parser.add_argument('--test-split', type=float, default=0.1, help='only relevant for synth_2d so far') ar = parser.parse_args() preprocess_args(ar) log_args(ar.log_dir, ar) return ar
def get_args(): parser = argparse.ArgumentParser() # BASICS parser.add_argument('--seed', type=int, default=None, help='sets random seed') parser.add_argument('--n-labels', type=int, default=10, help='number of labels/classes in data') parser.add_argument('--log-interval', type=int, default=10000, help='print updates after n steps') parser.add_argument('--base-log-dir', type=str, default='logs/gen/', help='path where logs for all runs are stored') parser.add_argument('--log-name', type=str, default=None, help='subdirectory for this run') parser.add_argument('--log-dir', type=str, default=None, help='override save path. constructed if None') parser.add_argument('--data', type=str, default='digits', help='options are digits and fashion') parser.add_argument('--synth-code_balanced', action='store_true', default=True, help='if true, make 60k synthetic code_balanced') # OPTIMIZATION parser.add_argument('--batch-size', '-bs', type=int, default=100) parser.add_argument('--test-batch-size', '-tbs', type=int, default=1000) parser.add_argument('--epochs', '-ep', type=int, default=5) parser.add_argument('--lr', '-lr', type=float, default=0.01, help='learning rate') parser.add_argument('--lr-decay', type=float, default=0.9, help='per epoch learning rate decay factor') # MODEL DEFINITION # parser.add_argument('--batch-norm', action='store_true', default=True, help='use batch norm in model') parser.add_argument('--d-code', '-dcode', type=int, default=5, help='random code dimensionality') parser.add_argument('--gen-spec', type=str, default='200', help='specifies hidden layers of generator') parser.add_argument('--kernel-sizes', '-ks', type=str, default='5,5', help='specifies conv gen kernel sizes') parser.add_argument('--n-channels', '-nc', type=str, default='16,8', help='specifies conv gen kernel sizes') parser.add_argument('--mmd-type', type=str, default='sphere', help='how to approx mmd', choices=['sphere', 'r+r']) # DP SPEC parser.add_argument('--d-rff', type=int, default=1000, help='number of random filters for apprixmate mmd') parser.add_argument('--rff-sigma', '-rffsig', type=str, default=None, help='standard dev. for filter sampling') parser.add_argument('--noise-factor', '-noise', type=float, default=5.0, help='privacy noise parameter') parser.add_argument('--flip-mnist', action='store_true', default=False, help='') ar = parser.parse_args() preprocess_args(ar) log_args(ar.log_dir, ar) return ar
def get_args(): parser = argparse.ArgumentParser() # BASICS parser.add_argument('--no-cuda', action='store_true', default=False, help='turns off gpu') parser.add_argument('--seed', type=int, default=None, help='sets random seed') parser.add_argument('--n-labels', type=int, default=10, help='number of labels/classes in data') parser.add_argument('--log-interval', type=int, default=100, help='print updates after n steps') parser.add_argument('--base-log-dir', type=str, default='logs/gen/', help='path where logs for all runs are stored') parser.add_argument('--log-name', type=str, default=None, help='subdirectory for this run') parser.add_argument('--log-dir', type=str, default=None, help='override save path. constructed if None') parser.add_argument('--data', type=str, default='digits', help='options are digits and fashion') parser.add_argument('--synth-mnist', action='store_true', default=True, help='if true, make 60k synthetic mnist') # OPTIMIZATION parser.add_argument('--batch-size', '-bs', type=int, default=500) parser.add_argument('--test-batch-size', '-tbs', type=int, default=1000) parser.add_argument('--epochs', '-ep', type=int, default=5) parser.add_argument('--lr', '-lr', type=float, default=0.01, help='learning rate') parser.add_argument('--lr-decay', type=float, default=0.9, help='per epoch learning rate decay factor') # MODEL DEFINITION parser.add_argument('--batch-norm', action='store_true', default=True, help='use batch norm in model') parser.add_argument('--gen-labels', action='store_true', default=True, help='generate labels as well as samples') parser.add_argument('--uniform-labels', action='store_true', default=True, help='assume uniform label distribution') parser.add_argument('--d-code', '-dcode', type=int, default=5, help='random code dimensionality') parser.add_argument('--gen-spec', type=str, default='200,100', help='specifies hidden layers of generator') parser.add_argument('--big-gen', action='store_true', default=False, help='False: gen as 2 hidden layers. True: 4') parser.add_argument('--real-mmd', action='store_true', default=False, help='for debug: dont approximate mmd') # DP SPEC parser.add_argument('--d-rff', type=int, default=1000, help='number of random filters for apprixmate mmd') parser.add_argument('--rff-sigma', '-rffsig', type=float, default=127.0, help='standard dev. for filter sampling') parser.add_argument('--noise-factor', '-noise', type=float, default=0.595, help='privacy noise parameter') ar = parser.parse_args() if ar.log_dir is None: ar.log_dir = get_log_dir(ar) if not os.path.exists(ar.log_dir): os.makedirs(ar.log_dir) preprocess_args(ar) log_args(ar.log_dir, ar) return ar
def get_args(): parser = argparse.ArgumentParser() # BASICS parser.add_argument('--no-cuda', action='store_true', default=False, help='turns off gpu') parser.add_argument('--seed', type=int, default=None, help='sets random seed') parser.add_argument('--n-labels', type=int, default=10, help='number of labels/classes in data') parser.add_argument('--log-interval', type=int, default=100, help='print updates after n steps') parser.add_argument('--base-log-dir', type=str, default='logs/gen/', help='path where logs for all runs are stored') parser.add_argument('--log-name', type=str, default=None, help='subdirectory for this run') parser.add_argument('--log-dir', type=str, default=None, help='override save path. constructed if None') parser.add_argument('--data', type=str, default='digits', help='options are digits and fashion') parser.add_argument('--synth-mnist', action='store_true', default=True, help='if true, make 60k synthetic mnist') # OPTIMIZATION parser.add_argument('--batch-size', '-bs', type=int, default=500) parser.add_argument('--test-batch-size', '-tbs', type=int, default=1000) parser.add_argument('--epochs', '-ep', type=int, default=7) parser.add_argument('--lr', '-lr', type=float, default=1e-3, help='learning rate') parser.add_argument('--lr-decay', type=float, default=0.9, help='per epoch learning rate decay factor') # MODEL DEFINITION parser.add_argument('--batch-norm', action='store_true', default=True, help='use batch norm in model') parser.add_argument('--gen-labels', action='store_true', default=True, help='generate labels as well as samples') parser.add_argument('--uniform-labels', action='store_true', default=True, help='assume uniform label distribution') parser.add_argument('--d-enc', '-denc', type=int, default=10, help='embedding space dimensionality') parser.add_argument('--d-code', '-dcode', type=int, default=10, help='random code dimensionality') parser.add_argument('--gen-spec', type=str, default='100,100', help='specifies hidden layers of generator') # DP SPEC parser.add_argument('--d-rff', type=int, default=10000, help='number of random filters for apprixmate mmd') parser.add_argument('--rff-sigma', '-rffsig', type=float, default=80.0, help='standard dev. for filter sampling') parser.add_argument('--noise-factor', '-noise', type=float, default=0.7, help='privacy noise parameter') # Autoencoder info parser.add_argument('--ae-no-bias', action='store_true', default=True, help='if true, AE has no bias units') parser.add_argument('--ae-bn', action='store_true', default=True, help='if true, AE uses batch norm') parser.add_argument('--ae-enc-spec', type=str, default='300,100', help='AE encoder hidden layers') parser.add_argument('--ae-dec-spec', type=str, default='100', help='AE decoder hidden layers') parser.add_argument('--ae-norm-data', action='store_true', default=False, help='if true, data was pre-processed') parser.add_argument('--ae-load-dir', type=str, default=None, help='path to where AE is stored') # outdated variants and args only relevant for automated loading - don't worry about those parser.add_argument('--ae-conv', action='store_true', default=False) parser.add_argument('--ae-label', action='store_true', default=False) parser.add_argument('--ae-ce-loss', action='store_true', default=False) parser.add_argument('--ae-clip', type=float, default=None) parser.add_argument('--ae-noise', type=float, default=None) parser.add_argument('--ae-siam-weight', '-wsiam', type=float, default=None) parser.add_argument('--ae-siam-margin', '-msiam', type=float, default=None) ar = parser.parse_args() if ar.log_dir is None: ar.log_dir = get_log_dir(ar) if not os.path.exists(ar.log_dir): os.makedirs(ar.log_dir) preprocess_args(ar) log_args(ar.log_dir, ar) return ar
def get_args(): parser = argparse.ArgumentParser() # BASICS parser.add_argument('--no-cuda', action='store_true', default=False, help='turns off gpu') parser.add_argument('--seed', type=int, default=None, help='sets random seed') parser.add_argument('--n-labels', type=int, default=10, help='number of labels/classes in data') parser.add_argument('--log-interval', type=int, default=100, help='print updates after n steps') parser.add_argument('--base-log-dir', type=str, default='logs/ae/', help='path where logs for all runs are stored') parser.add_argument('--log-name', type=str, default=None, help='subdirectory for this run') parser.add_argument('--log-dir', type=str, default=None, help='override save path. constructed if None') parser.add_argument('--verbose', action='store_true', default=False, help='turns on more debug/status printing') parser.add_argument('--data', type=str, default='digits', help='options are digits and fashion') parser.add_argument('--norm-data', action='store_true', default=False, help='if true, preprocess data') # OPTIMIZATION parser.add_argument('--batch-size', '-bs', type=int, default=500) parser.add_argument('--test-batch-size', '-tbs', type=int, default=1000) parser.add_argument('--epochs', '-ep', type=int, default=10) parser.add_argument('--lr', '-lr', type=float, default=1e-3, help='learning rate') parser.add_argument('--lr-decay', type=float, default=0.8, help='per epoch learning rate decay factor') parser.add_argument('--optimizer', '-opt', type=str, default='adam') parser.add_argument('--siam-loss-weight', '-wsiam', type=float, default=100., help='weight of siamese loss') parser.add_argument('--siam-loss-margin', '-msiam', type=float, default=5., help='margin used in siamese loss') # MODEL DEFINITION parser.add_argument('--d-enc', '-denc', type=int, default=10, help='embedding space dimensionality') parser.add_argument('--no-bias', action='store_true', default=True, help='remove bias units') parser.add_argument('--batch-norm', action='store_true', default=True, help='use batch norm in encoder') parser.add_argument('--enc-spec', '-s-enc', type=str, default='300,100', help='encoder hidden layers') parser.add_argument('--dec-spec', '-s-dec', type=str, default='100', help='decoder hidden layers') parser.add_argument('--conv-ae', action='store_true', default=False, help='if true, use convolutional AE (not used)') parser.add_argument('--flat-dec', action='store_true', default=False, help='if conv-ae, use smaller model (not used)') parser.add_argument('--ce-loss', action='store_true', default=False, help='pixelwise cross-entropy loss (not used)') parser.add_argument('--label-ae', action='store_true', default=False, help='autoencode labels as well (not used)') # DP SPEC parser.add_argument('--clip-norm', '-clip', type=float, default=0.01, help='samplewise gradient L2 clip norm') parser.add_argument('--noise-factor', '-noise', type=float, default=0.7, help='DP-SGD noise parameter') parser.add_argument('--clip-per-layer', action='store_true', default=False, help='if true, clip per layer (not used)') parser.add_argument('--layer-clip-norms', '-layer-clip', type=str, default=None, help='perlayer clip norms(not used)') parser.add_argument('--noise-up-enc', action='store_true', default=False, help='debug: apply DP-SGD to encoder too') ar = parser.parse_args() if ar.log_dir is None: ar.log_dir = get_log_dir(ar) if not os.path.exists(ar.log_dir): os.makedirs(ar.log_dir) preprocess_args(ar) log_args(ar.log_dir, ar) return ar