Skip to content

Commit ced4695

Browse files
authored
doc: miscellaneous improvements (#70)
* doc: miscellaneous improvements * doc: miscellaneous improvements
1 parent 66afef5 commit ced4695

8 files changed

+111
-124
lines changed

CHANGELOG.rst

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
=========
33

4+
+---------------+-----------------------------------------------------------+
5+
| Badge | Meaning |
6+
+===============+===========================================================+
7+
| |Feature| | Add something that cannot be achieved before. |
8+
+---------------+-----------------------------------------------------------+
9+
| |Efficiency| | Improve the efficiency on the computation or memory. |
10+
+---------------+-----------------------------------------------------------+
11+
| |Enhancement| | Miscellaneous minor improvements. |
12+
+---------------+-----------------------------------------------------------+
13+
| |Fix| | Fix up something that does not work as expected. |
14+
+---------------+-----------------------------------------------------------+
15+
| |API| | You will need to change the code to have the same effect. |
16+
+---------------+-----------------------------------------------------------+
17+
418
Ver 0.1.*
519
---------
620

@@ -42,6 +56,6 @@ Beta
4256
.. |MajorFeature| replace:: :raw-html:`<span class="badge badge-success">Major Feature</span>` :raw-latex:`{\small\sc [Major Feature]}`
4357
.. |Feature| replace:: :raw-html:`<span class="badge badge-success">Feature</span>` :raw-latex:`{\small\sc [Feature]}`
4458
.. |Efficiency| replace:: :raw-html:`<span class="badge badge-info">Efficiency</span>` :raw-latex:`{\small\sc [Efficiency]}`
45-
.. |Enhancement| replace:: :raw-html:`<span class="badge badge-info">Enhancement</span>` :raw-latex:`{\small\sc [Enhancement]}`
59+
.. |Enhancement| replace:: :raw-html:`<span class="badge badge-primary">Enhancement</span>` :raw-latex:`{\small\sc [Enhancement]}`
4660
.. |Fix| replace:: :raw-html:`<span class="badge badge-danger">Fix</span>` :raw-latex:`{\small\sc [Fix]}`
4761
.. |API| replace:: :raw-html:`<span class="badge badge-warning">API Change</span>` :raw-latex:`{\small\sc [API Change]}`

README.rst

+14-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
Ensemble PyTorch
2727
================
2828

29-
Ensemble PyTorch is a unified ensemble framework for PyTorch to improve the performance and robustness of your deep learning model. Please refer to our `documentation <https://ensemble-pytorch.readthedocs.io/>`__ for details.
29+
Ensemble PyTorch is a unified ensemble framework for PyTorch to easily improve the performance and robustness of your deep learning model.
30+
31+
Resources
32+
---------
33+
34+
* `Document <https://ensemble-pytorch.readthedocs.io/>`__
35+
* `Source Code <https://github.com/xuyxu/Ensemble-Pytorch>`__
36+
* `Experiment <https://ensemble-pytorch.readthedocs.io/en/stable/experiment.html>`__
3037

3138
Installation
3239
------------
@@ -49,17 +56,17 @@ To use the latest version, you need to install the package from source:
4956
5057
$ git clone https://github.com/xuyxu/Ensemble-Pytorch.git
5158
$ cd Ensemble-Pytorch
52-
$ pip install -r requirements.txt (Optional)
59+
$ pip install -r requirements.txt
5360
$ python setup.py install
5461
55-
Minimal Example on How to Use
56-
-----------------------------
62+
Example
63+
-------
5764

5865
.. code:: python
5966
60-
from torchensemble import VotingClassifier # a classic ensemble method
67+
from torchensemble import VotingClassifier # Voting is a classic ensemble strategy
6168
62-
# Load your data
69+
# Load data
6370
train_loader = DataLoader(...)
6471
test_loader = DataLoader(...)
6572
@@ -73,7 +80,7 @@ Minimal Example on How to Use
7380
weight_decay=weight_decay) # weight decay of the optimizer
7481
7582
# Set the scheduler
76-
model.set_scheduler("CosineAnnealingLR", T_max=epochs) # optional
83+
model.set_scheduler("CosineAnnealingLR", T_max=epochs) # (optional) learning rate scheduler
7784
7885
# Train
7986
model.fit(train_loader,
@@ -103,11 +110,6 @@ Supported Ensemble
103110
| Fast Geometric Ensemble | Sequential | `[NeurIPS'18] Loss Surfaces, Mode Connectivity, and Fast Ensembling of DNNs <https://arxiv.org/pdf/1802.10026;Loss>`__ | fast_geometric.py |
104111
+-------------------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+
105112

106-
Experiment
107-
----------
108-
109-
Please refer to the `experiment part <https://ensemble-pytorch.readthedocs.io/en/stable/experiment.html>`__ of our documentation.
110-
111113
Package Dependency
112114
------------------
113115

docs/experiment.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Experiments
44
Setup
55
~~~~~
66

7-
Experiments here are designed to evaluate the performance of each ensemble implemented in torchensemble. We have collected four configurations on dataset and base estimator, as shown in the table below. In addition, scripts on producing all figures below are available on `GitHub <https://github.com/xuyxu/Ensemble-Pytorch/tree/master/docs/plotting>`__.
7+
Experiments here are designed to evaluate the performance of each ensemble implemented in Ensemble-PyTorch. We have collected four different configurations on dataset and base estimator, as shown in the table below. In addition, scripts on producing all figures below are available on `GitHub <https://github.com/xuyxu/Ensemble-Pytorch/tree/master/docs/plotting>`__.
88

99
.. table::
1010
:align: center
@@ -21,14 +21,14 @@ Experiments here are designed to evaluate the performance of each ensemble imple
2121
|ResNet\@CIFAR-100 | ResNet-18 | CIFAR-100 | 2, 5, 7, 10 |
2222
+------------------+----------------+-----------+-------------------+
2323

24-
1. Data augmentations were adopted on **CIFAR-10** and **CIFAR-100** datasets.
24+
1. Data augmentations were adopted on both **CIFAR-10** and **CIFAR-100** datasets.
2525
2. For **LeNet-5**, the ``Adam`` optimizer with learning rate ``1e-3`` and weight decay ``5e-4`` was used.
2626
3. For **ResNet-18**, the ``SGD`` optimizer with learning rate ``1e-1``, weight decay ``5e-4``, and momentum ``0.9`` was used.
2727
4. Reference code: `ResNet-18 on CIFAR-10 <https://github.com/kuangliu/pytorch-cifar>`__ and `ResNet-18 on CIFAR-100 <https://github.com/weiaicunzai/pytorch-cifar100>`__.
2828

2929
.. tip::
3030

31-
For each experiment shwon below, we have added some comments that may be worthy of your attention. Feel free to open an `issue <https://github.com/xuyxu/Ensemble-Pytorch/issues>`__ if you have any question on the results.
31+
For each experiment shown below, we have added some comments that may be worthy of your attention. Feel free to open an `issue <https://github.com/xuyxu/Ensemble-Pytorch/issues>`__ if you have any question on the results.
3232

3333
LeNet\@MNIST
3434
~~~~~~~~~~~~
@@ -39,8 +39,8 @@ LeNet\@MNIST
3939

4040
* MNIST is a very easy dataset, and the testing acc of a single LeNet-5 estimator is over 99%
4141
* voting and bagging are the most effective ensemble in this case
42-
* bagging is even better than voting since the bootstrap sampling on training data ingests more diversity into the ensemble than voting
43-
* fusion does not perform well in this case, possibly because the model complexity of a single LeNet-5 estimator is already enough for MNIST. Therefore, simply encapsulating several LeNet-5 estimators into a large model will only make the over-fitting problem more severe.
42+
* bagging is even better than voting since the bootstrap sampling on training data ingests more diversity into the ensemble
43+
* fusion does not perform well in this case, possibly because the model complexity of a single LeNet-5 estimator is already sufficient for MNIST. Therefore, simply encapsulating several LeNet-5 estimators into a large model will only make the over-fitting problem more severe.
4444

4545
LeNet\@CIFAR-10
4646
~~~~~~~~~~~~~~~
@@ -50,7 +50,7 @@ LeNet\@CIFAR-10
5050
:width: 400
5151

5252
* CIFAR-10 is a hard dataset for LeNet-5, and the testing acc of a single LeNet-5 estimator is around 70%
53-
* gradient boosting is the most effective ensemble because it is able to boost the performance of weak estimators by a large margin as a bias-reduction ensemble method
53+
* gradient boosting is the most effective ensemble because it is able to improve the performance of weak estimators by a large margin as a bias-reduction ensemble method
5454
* bagging is worse than voting since less training data are available
5555
* snapshot ensemble, more precisely, the customized learning rate scheduler in snapshot ensemble, does not adapt well with LeNet-5 (more training epochs are needed)
5656

@@ -80,4 +80,4 @@ ResNet\@CIFAR-100
8080
Acknowledgement
8181
~~~~~~~~~~~~~~~
8282

83-
We would like to thank the `LAMDA Group <http://www.lamda.nju.edu.cn/MainPage.ashx>`__ from Nanjing University for providing us with the powerful V-100 GPU server.
83+
We would like to thank the `LAMDA Group <http://www.lamda.nju.edu.cn/MainPage.ashx>`__ from Nanjing University for providing us with the powerful V-100 GPU server.

docs/index.rst

+22-49
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,57 @@
22
:align: center
33
:width: 400
44

5-
|github|_ |readthedocs|_ |codecov|_ |python|_ |pypi|_ |license|_
6-
7-
.. |github| image:: https://github.com/xuyxu/Ensemble-Pytorch/workflows/torchensemble-CI/badge.svg
8-
.. _github: https://github.com/xuyxu/Ensemble-Pytorch/actions
9-
10-
.. |readthedocs| image:: https://readthedocs.org/projects/ensemble-pytorch/badge/?version=latest
11-
.. _readthedocs: https://ensemble-pytorch.readthedocs.io/en/latest/index.html
12-
13-
.. |codecov| image:: https://codecov.io/gh/xuyxu/Ensemble-Pytorch/branch/master/graph/badge.svg?token=2FXCFRIDTV
14-
.. _codecov: https://codecov.io/gh/xuyxu/Ensemble-Pytorch
15-
16-
.. |python| image:: https://img.shields.io/badge/python-3.6+-blue?logo=python
17-
.. _python: https://www.python.org/
18-
19-
.. |pypi| image:: https://img.shields.io/pypi/v/torchensemble
20-
.. _pypi: https://pypi.org/project/torchensemble/
21-
22-
.. |license| image:: https://img.shields.io/github/license/xuyxu/Ensemble-Pytorch
23-
.. _license: https://github.com/xuyxu/Ensemble-Pytorch/blob/master/LICENSE
24-
255
Ensemble PyTorch Documentation
266
==============================
277

28-
.. rst-class:: center
29-
30-
| |:homes:| `GitHub <https://github.com/xuyxu/Ensemble-Pytorch>`__ | |:book:| `ReadtheDocs <https://readthedocs.org/projects/ensemble-pytorch/>`__ | |:hammer_and_wrench:| `Codecov <https://codecov.io/gh/xuyxu/Ensemble-Pytorch>`__
31-
|
32-
33-
Ensemble PyTorch is a unified ensemble framework for PyTorch to improve the performance and robustness of your deep learning model. It provides:
8+
Ensemble PyTorch is a unified ensemble framework for PyTorch to easily improve the performance and robustness of your deep learning model. It provides:
349

3510
* |:arrow_up_small:| Easy ways to improve the performance and robustness of your deep learning model.
3611
* |:eyes:| Easy-to-use APIs on training and evaluating the ensemble.
3712
* |:zap:| High training efficiency with parallelization.
3813

39-
| This package is under active development. Please feel free to open an `issue <https://github.com/xuyxu/Ensemble-Pytorch/issues>`__ if your have any problem. In addition, any feature request or `pull request <https://github.com/xuyxu/Ensemble-Pytorch/pulls>`__ would be highly welcomed.
40-
4114
Guidepost
4215
---------
4316

4417
* To get started, please refer to `Quick Start <./quick_start.html>`__;
4518
* To learn more about ensemble methods supported, please refer to `Introduction <./introduction.html>`__;
4619
* If you are confused on which ensemble method to use, our `experiments <./experiment.html>`__ and the instructions in `guidance <./guide.html>`__ may be helpful.
4720

48-
Minimal Example on How to Use
49-
-----------------------------
21+
Example
22+
-------
5023

5124
.. code:: python
5225
53-
from torchensemble import VotingClassifier # a classic ensemble method
26+
from torchensemble import VotingClassifier # Voting is a classic ensemble strategy
5427
55-
# Load your data
56-
train_loader = DataLoader(...)
57-
test_loader = DataLoader(...)
28+
# Load data
29+
train_loader = DataLoader(...)
30+
test_loader = DataLoader(...)
5831
59-
# Define the ensemble
60-
model = VotingClassifier(estimator=base_estimator, # your deep learning model
61-
n_estimators=10) # the number of base estimators
32+
# Define the ensemble
33+
model = VotingClassifier(estimator=base_estimator, # your deep learning model
34+
n_estimators=10) # the number of base estimators
6235
63-
# Set the optimizer
64-
model.set_optimizer("Adam", # parameter optimizer
65-
lr=learning_rate, # learning rate of the optimizer
66-
weight_decay=weight_decay) # weight decay of the optimizer
36+
# Set the optimizer
37+
model.set_optimizer("Adam", # parameter optimizer
38+
lr=learning_rate, # learning rate of the optimizer
39+
weight_decay=weight_decay) # weight decay of the optimizer
6740
68-
# Set the scheduler
69-
model.set_scheduler("CosineAnnealingLR", T_max=epochs) # optional
41+
# Set the scheduler
42+
model.set_scheduler("CosineAnnealingLR", T_max=epochs) # (optional) learning rate scheduler
7043
71-
# Train
72-
model.fit(train_loader,
73-
epochs=epochs) # the number of training epochs
44+
# Train
45+
model.fit(train_loader,
46+
epochs=epochs) # the number of training epochs
7447
75-
# Evaluate
76-
acc = model.predict(test_loader) # testing accuracy
48+
# Evaluate
49+
acc = model.predict(test_loader) # testing accuracy
7750
7851
Content
7952
-------
8053

8154
.. toctree::
82-
:maxdepth: 2
55+
:maxdepth: 1
8356

8457
Quick Start <quick_start>
8558
Introduction <introduction>

docs/introduction.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ During the training stage of each base estimator :math:`h^m`, an adversarial sam
7070

7171
Same as Voting and Bagging, the output of ``AdversarialTrainingClassifier`` or ``AdversarialTrainingRegressor`` during the evaluating stage is the average over predictions from all base estimators.
7272

73+
Fast Geometric Ensemble [3]_
74+
----------------------------
75+
76+
Motivated by geometric insights on the loss surface of deep neural networks, Fast Geometirc Ensembling (FGE) is an efficient ensemble that uses a customized learning rate scheduler to generate base estimators, similar to snapshot ensemble.
77+
7378
**References**
7479

7580
.. [1] Huang Gao, Sharon Yixuan Li, Geoff Pleisset, et al., "Snapshot ensembles: Train 1, get m for free." ICLR, 2017.
76-
.. [2] Balaji Lakshminarayanan, Alexander Pritzel, Charles Blundell., "Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles." NIPS 2017.
81+
.. [2] Balaji Lakshminarayanan, Alexander Pritzel, Charles Blundell., "Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles." NIPS 2017.
82+
.. [3] Timur Garipov, Pavel Izmailov, Dmitrii Podoprikhin et al., "Loss Surfaces, Mode Connectivity, and Fast Ensembling of DNNs." NeurIPS, 2018.

docs/parameters.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Parameters
22
==========
33

4-
This page provides the API reference of ``torchensemble``, please also refer to `Introduction <./introduction.html>`__ for details.
4+
This page provides the API reference of :mod:`torchensemble`.
55

66
Fusion
77
------
@@ -48,7 +48,7 @@ Bagging
4848
In bagging-based ensemble methods, each base estimator is trained
4949
independently. In addition, sampling with replacement is conducted on the
5050
training data to further encourage the diversity between different base
51-
estimators in the ensemble model.
51+
estimators in the ensemble.
5252

5353
BaggingClassifier
5454
*****************
@@ -71,7 +71,7 @@ computed based on the ground truth and the output from base estimators
7171
fitted before, using ordinary least square.
7272

7373
.. tip::
74-
The input argument ``shrinkage_rate`` in :mod:`gradient_boosting` is also known as learning rate in other gradient boosting libraries such as `XGBoost <https://xgboost.readthedocs.io/en/latest/>`__. However, its meaning is totally different from the meaning of learning rate in the context of parameter optimizer in deep learning.
74+
The input argument ``shrinkage_rate`` in :class:`gradient_boosting` is also known as learning rate in other gradient boosting libraries such as `XGBoost <https://xgboost.readthedocs.io/en/latest/>`__. However, its meaning is totally different from the meaning of learning rate in the context of parameter optimizer in deep learning.
7575

7676
GradientBoostingClassifier
7777
**************************
@@ -139,7 +139,7 @@ Fast Geometric Ensemble
139139
-----------------------
140140

141141
Motivated by geometric insights on the loss surface of deep neural networks,
142-
Fast Geometirc Ensembling (FGE) is an efficient ensemble that uses a
142+
Fast Geometric Ensembling (FGE) is an efficient ensemble that uses a
143143
customized learning rate scheduler to generate base estimators, similar to
144144
snapshot ensemble.
145145

0 commit comments

Comments
 (0)