options.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Python version: 3.6
  4. import argparse
  5. def args_parser():
  6. parser = argparse.ArgumentParser()
  7. # federated arguments
  8. parser.add_argument('--epochs', type=int, default=10, help="rounds of training")
  9. parser.add_argument('--num_users', type=int, default=100, help="number of users: K")
  10. parser.add_argument('--frac', type=float, default=0.1, help='the fraction of clients: C')
  11. parser.add_argument('--local_ep', type=int, default=5, help="the number of local epochs: E")
  12. parser.add_argument('--local_bs', type=int, default=10, help="local batch size: B")
  13. parser.add_argument('--lr', type=float, default=0.01, help='learning rate')
  14. parser.add_argument('--momentum', type=float, default=0.5, help='SGD momentum (default: 0.5)')
  15. # model arguments
  16. parser.add_argument('--model', type=str, default='mlp', help='model name')
  17. parser.add_argument('--kernel_num', type=int, default=9, help='number of each kind of kernel')
  18. parser.add_argument('--kernel_sizes', type=str, default='3,4,5',
  19. help='comma-separated kernel size to use for convolution')
  20. parser.add_argument('--norm', type=str, default='batch_norm',
  21. help="batch_norm, layer_norm, or None")
  22. parser.add_argument('--num_filters', type=int, default=32,
  23. help="number of filters for conv nets -- 32 for miniimagenet, 64 for omiglot.")
  24. parser.add_argument('--max_pool', type=str, default='True',
  25. help="Whether use max pooling rather than strided convolutions")
  26. # other arguments
  27. parser.add_argument('--dataset', type=str, default='mnist', help="name of dataset")
  28. parser.add_argument('--iid', type=int, default=0,
  29. help='whether i.i.d or not, 1 for iid, 0 for non-iid')
  30. parser.add_argument('--unequal', type=int, default=0,
  31. help='in non-i.i.d, whether data split among clients is equal or not, 1 for unequal split')
  32. parser.add_argument('--num_classes', type=int, default=10, help="number of classes")
  33. parser.add_argument('--num_channels', type=int, default=1, help="number of channels of imgs")
  34. parser.add_argument('--gpu', type=int, default=1, help="GPU ID")
  35. parser.add_argument('--stopping_rounds', type=int, default=10, help='rounds of early stopping')
  36. parser.add_argument('--verbose', type=int, default=1,
  37. help='verbose print, 1 for True, 0 for False')
  38. parser.add_argument('--seed', type=int, default=1, help='random seed (default: 1)')
  39. args = parser.parse_args()
  40. return args