Skip to main content

A PyTorch Dataloader compatible batch size scheduler library.

Project description

bs-scheduler

A Batch Size Scheduler library compatible with PyTorch DataLoaders.


Documentation


Why use a Batch Size Scheduler?

  • Using a big batch size has several advantages:
    • Better hardware utilization.
    • Enhanced parallelism.
    • Faster training.
  • However, using a big batch size from the start may lead to a generalization gap.
  • Therefore, the solution is to gradually increase the batch size, similar to a learning rate decay policy.
  • See Don't Decay the Learning Rate, Increase the Batch Size.

Available Schedulers

Batch Size Schedulers

  1. LambdaBS - sets the batch size to the base batch size times a given lambda.
  2. MultiplicativeBS - sets the batch size to the current batch size times a given lambda.
  3. StepBS - multiplies the batch size with a given factor at a given number of steps.
  4. MultiStepBS - multiplies the batch size with a given factor each time a milestone is reached.
  5. ConstantBS - multiplies the batch size by a given factor once and decreases it again to its base value after a given number of steps.
  6. LinearBS - increases the batch size by a linearly changing multiplicative factor for a given number of steps.
  7. ExponentialBS - increases the batch size by a given $\gamma$ each step.
  8. PolynomialBS - increases the batch size using a polynomial function in a given number of steps.
  9. CosineAnnealingBS - increases the batch size to a maximum batch size and decreases it again following a cyclic cosine curve.
  10. IncreaseBSOnPlateau - increases the batch size each time a given metric has stopped improving for a given number of steps.
  11. CyclicBS - cycles the batch size between two boundaries with a constant frequency, while also scaling the distance between boundaries.
  12. CosineAnnealingBSWithWarmRestarts - increases the batch size to a maximum batch size following a cosine curve, then restarts while also scaling the number of iterations until the next restart.
  13. OneCycleBS - decreases the batch size to a minimum batch size then increases it to a given maximum batch size, following a linear or cosine annealing strategy.
  14. SequentialBS - calls a list of schedulers sequentially given a list of milestone points which reflect which scheduler should be called when.
  15. ChainedBSScheduler - chains a list of batch size schedulers and calls them together each step.

Installation

Please install PyTorch first before installing this repository.

pip install bs-scheduler

Licensing

The library is licensed under the BSD-3-Clause license.

Citation

To be added...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bs_scheduler-1.0.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bs_scheduler-1.0.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file bs_scheduler-1.0.0.tar.gz.

File metadata

  • Download URL: bs_scheduler-1.0.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for bs_scheduler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2b70c3e3cb975dfe93b2d38ace156bd584387fc24981c3f4ea9e67adcbd5ed95
MD5 35f69d806007aa6ab2d0d2a37ee1de58
BLAKE2b-256 c35632947233a1723cba33737a51d19b0bae6e7da9354827a6e374fd80f60048

See more details on using hashes here.

File details

Details for the file bs_scheduler-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bs_scheduler-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for bs_scheduler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1b0fabe45573596e555b9e60965568d931c2e06f4d1417137ab9db636439eef
MD5 10899145651f0e02e160692c15e40f7c
BLAKE2b-256 a797b3f113adbe55d4c085ec79aa5d70c8e1f57817d9e3875398c6a1c91dd4ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page