Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMoC (Adaptive Momentum Coefficient for Neural Network Optimization)

About

The code accompanying our ECML-PKDD 2020 paper Adaptive Momentum Coefficient for Neural Network Optimization.

Summary

Adaptive Momentum Coefficient (AMoC) utilizes the inner product of the gradient and the previous update to the parameters, to effectively control the amount of weight put on the momentum term based on the change of direction in the optimization path. It is easy to implement and its computational overhead over momentum methods is negligible. Extensive empirical results on both convex and neural network objectives show that AMoC performs well in practise and compares favourably with other first and second-order optimization algorithms.

Contents

The repository contains the implementation of the AMoC optimizer along with the Deep Autoencoder experiments on the MNIST dataset included in the paper.

.
├── amoc/                # the `amoc` Python package
│   ├── __init__.py
│   ├── models.py         # AE_MNIST autoencoder
│   └── optimizer.py      # AMoC optimizer
├── scripts/
│   └── train.py          # training/evaluation entry point
├── tests/
│   └── test_optimizer.py
├── assets/
│   └── amoc.png
├── pyproject.toml
└── requirements.txt

Hyperparameters

Variables and hyperparameters including learning rate (ε), beta (β) and momentum (μ) can be modified in the scripts.

Requirements

Requires Python 3.8+ and PyTorch 1.9+ (CUDA is optional; the code falls back to CPU automatically). Install the package and its dependencies in editable mode:

pip install -e .

Usage

Train the MNIST autoencoder with AMoC (downloads MNIST automatically on first run):

python scripts/train.py --algorithm AMoC --num-epochs 500 --lr 5e-3 --momentum 0.99 --beta 0.1

Run python scripts/train.py --help for the full list of options, including switching --algorithm between AMoC, AMoC-N (Nesterov variant), SGD, Heavy Ball, Nesterov, Adam, and AMSGrad. Results (model weights, loss history, and hyperparameters) are saved under <output-dir>/<model-name>/<model-name>_<experiment-num>/.

Tests

pytest tests/

Citation

If you use this code, please cite the paper:

@inproceedings{amoc2020,
  title     = {Adaptive Momentum Coefficient for Neural Network Optimization},
  booktitle = {Proceedings of the European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML-PKDD)},
  year      = {2020}
}

About

Adaptive Momentum Coefficient for Neural Network Optimization

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages