Skip to main content

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...

Metadata

Release files for bs-scheduler 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bs-scheduler 1.0.2
File Size Uploaded
bs_scheduler-1.0.2.tar.gz 26.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bs-scheduler 1.0.2
File Interpreter ABI Platform
bs_scheduler-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.2 kB

Release files / bs_scheduler-1.0.2.tar.gz

Download URL bs_scheduler-1.0.2.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
52694013aec77469c998233dbbf1ed39707afa7c397f02fc9c48dcb22e48949c
BLAKE2b-256 checksum
How to use checksums
4e0b32621a3ec487387874d6605a89078319179bfdf90a91d315ff69e77e3637
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / bs_scheduler-1.0.2-py3-none-any.whl

Download URL bs_scheduler-1.0.2-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
936d68a774232cd5ecdc5bc17a7e4149eac13ff24d86433c4ce4d86abc135528
BLAKE2b-256 checksum
How to use checksums
985d2eb661c0a9dd0307ad538e9db0a5a71f83c248cdb0b832e5487b97beb807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page