Coder Social home page Coder Social logo

guojl7 / ensemble-pytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from watermelondrip/ensemble-pytorch

0.0 0.0 0.0 1.56 MB

A unified ensemble framework for PyTorch to improve the performance and robustness of your deep learning model.

Home Page: https://ensemble-pytorch.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Shell 0.06% Python 99.92% Batchfile 0.02%

ensemble-pytorch's Introduction

./docs/_images/badge_small.png

github readthedocs codecov license

Ensemble PyTorch

A unified ensemble framework for pytorch to easily improve the performance and robustness of your deep learning model. Ensemble-PyTorch is part of the pytorch ecosystem, which requires the project to be well maintained.

Installation

pip install torchensemble

Example

from torchensemble import VotingClassifier  # voting is a classic ensemble strategy

# Load data
train_loader = DataLoader(...)
test_loader = DataLoader(...)

# Define the ensemble
ensemble = VotingClassifier(
    estimator=base_estimator,               # estimator is your pytorch model
    n_estimators=10,                        # number of base estimators
)

# Set the optimizer
ensemble.set_optimizer(
    "Adam",                                 # type of parameter optimizer
    lr=learning_rate,                       # learning rate of parameter optimizer
    weight_decay=weight_decay,              # weight decay of parameter optimizer
)

# Set the learning rate scheduler
ensemble.set_scheduler(
    "CosineAnnealingLR",                    # type of learning rate scheduler
    T_max=epochs,                           # additional arguments on the scheduler
)

# Train the ensemble
ensemble.fit(
    train_loader,
    epochs=epochs,                          # number of training epochs
)

# Evaluate the ensemble
acc = ensemble.evaluate(test_loader)         # testing accuracy

Supported Ensemble

Ensemble Name Type Source Code Problem
Fusion Mixed fusion.py Classification / Regression
Voting [1] Parallel voting.py Classification / Regression
Neural Forest Parallel voting.py Classification / Regression
Bagging [2] Parallel bagging.py Classification / Regression
Gradient Boosting [3] Sequential gradient_boosting.py Classification / Regression
Snapshot Ensemble [4] Sequential snapshot_ensemble.py Classification / Regression
Adversarial Training [5] Parallel adversarial_training.py Classification / Regression
Fast Geometric Ensemble [6] Sequential fast_geometric.py Classification / Regression
Soft Gradient Boosting [7] Parallel soft_gradient_boosting.py Classification / Regression

Dependencies

  • scikit-learn>=0.23.0
  • torch>=1.4.0
  • torchvision>=0.2.2

Reference

[1]Zhou, Zhi-Hua. Ensemble Methods: Foundations and Algorithms. CRC press, 2012.
[2]Breiman, Leo. Bagging Predictors. Machine Learning (1996): 123-140.
[3]Friedman, Jerome H. Greedy Function Approximation: A Gradient Boosting Machine. Annals of Statistics (2001): 1189-1232.
[4]Huang, Gao, et al. Snapshot Ensembles: Train 1, Get M For Free. ICLR, 2017.
[5]Lakshminarayanan, Balaji, et al. Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles. NIPS, 2017.
[6]Garipov, Timur, et al. Loss Surfaces, Mode Connectivity, and Fast Ensembling of DNNs. NeurIPS, 2018.
[7]Feng, Ji, et al. Soft Gradient Boosting Machine. ArXiv, 2020.

Thanks to all our contributors

contributors

ensemble-pytorch's People

Contributors

allcontributors[bot] avatar arcify avatar by256 avatar cspsampedro avatar federicov avatar gardberg avatar mttgdd avatar nolaurence avatar sarthakjariwala avatar sunhaozhe avatar xuyxu avatar zzzzwj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.