Skip to content

Commit

Permalink
Merge branch 'JDRomano2-nn'
Browse files Browse the repository at this point in the history
  • Loading branch information
Weixuan committed Jun 1, 2020
2 parents 81a8c31 + 7d6c4e1 commit 1c009c6
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@

<!--
MkDocs version : 1.0
Build Date UTC : 2020-05-29 15:57:34
Build Date UTC : 2020-06-01 22:06:11
-->
8 changes: 4 additions & 4 deletions docs/installing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@
<li>
<p><a href="https://joblib.readthedocs.io/en/latest/">joblib</a></p>
</li>
<li>
<p><a href="https://pytorch.org/">PyTorch</a></p>
</li>
</ul>
<p>Most of the necessary Python packages can be installed via the <a href="https://www.continuum.io/downloads">Anaconda Python distribution</a>, which we strongly recommend that you use. We also strongly recommend that you use of Python 3 over Python 2 if you're given the choice.</p>
<p>You can install TPOT using <code>pip</code> or <code>conda-forge</code>.</p>
Expand All @@ -202,6 +199,8 @@ <h2 id="pip">pip</h2>
<pre><code class="Shell">pip install scikit-mdr skrebate
</code></pre>

<p>To enable support for <a href="https://pytorch.org/">PyTorch</a>-based neural networks (TPOT-NN), you will need to install PyTorch. TPOT-NN will work with either CPU or GPU PyTorch, but we strongly recommend using a GPU version, if possible, as CPU PyTorch models tend to train very slowly.</p>
<p>We recommend following <a href="https://pytorch.org/get-started/locally/">PyTorch's installation instructions</a> customized for your operating system and Python distribution.</p>
<p>Finally to install TPOT itself, run the following command:</p>
<pre><code class="Shell">pip install tpot
</code></pre>
Expand All @@ -212,9 +211,10 @@ <h2 id="conda-forge">conda-forge</h2>
</code></pre>

<p>To install additional dependencies you can use:</p>
<pre><code class="Shell">conda install -c conda-forge tpot xgboost dask dask-ml scikit-mdr skrebate pytorch
<pre><code class="Shell">conda install -c conda-forge tpot xgboost dask dask-ml scikit-mdr skrebate
</code></pre>

<p>As mentioned above, we recommend following <a href="https://pytorch.org/get-started/locally/">PyTorch's installation instructions</a> for installing it to enable support for <a href="https://pytorch.org/">PyTorch</a>-based neural networks (TPOT-NN).</p>
<h2 id="installation-problems">Installation problems</h2>
<p>Please <a href="https://github.com/EpistasisLab/tpot/issues/new">file a new issue</a> if you run into installation problems.</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,52 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://epistasislab.github.io/tpot/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/installing/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/using/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/api/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/examples/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/contributing/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/releases/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/citing/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/support/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://epistasislab.github.io/tpot/related/</loc>
<lastmod>2020-05-29</lastmod>
<lastmod>2020-06-01</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>
Binary file modified docs/sitemap.xml.gz
Binary file not shown.
10 changes: 7 additions & 3 deletions docs_sources/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ TPOT is built on top of several existing Python libraries, including:

* [joblib](https://joblib.readthedocs.io/en/latest/)

* [PyTorch](https://pytorch.org/)

Most of the necessary Python packages can be installed via the [Anaconda Python distribution](https://www.continuum.io/downloads), which we strongly recommend that you use. We also strongly recommend that you use of Python 3 over Python 2 if you're given the choice.

You can install TPOT using `pip` or `conda-forge`.
Expand Down Expand Up @@ -58,6 +56,10 @@ If you plan to use the [TPOT-MDR configuration](https://arxiv.org/abs/1702.01780
pip install scikit-mdr skrebate
```

To enable support for [PyTorch](https://pytorch.org/)-based neural networks (TPOT-NN), you will need to install PyTorch. TPOT-NN will work with either CPU or GPU PyTorch, but we strongly recommend using a GPU version, if possible, as CPU PyTorch models tend to train very slowly.

We recommend following [PyTorch's installation instructions](https://pytorch.org/get-started/locally/) customized for your operating system and Python distribution.

Finally to install TPOT itself, run the following command:

```Shell
Expand All @@ -75,9 +77,11 @@ conda install -c conda-forge tpot
To install additional dependencies you can use:

```Shell
conda install -c conda-forge tpot xgboost dask dask-ml scikit-mdr skrebate pytorch
conda install -c conda-forge tpot xgboost dask dask-ml scikit-mdr skrebate
```

As mentioned above, we recommend following [PyTorch's installation instructions](https://pytorch.org/get-started/locally/) for installing it to enable support for [PyTorch](https://pytorch.org/)-based neural networks (TPOT-NN).

## Installation problems

Please [file a new issue](https://github.com/EpistasisLab/tpot/issues/new) if you run into installation problems.
1 change: 1 addition & 0 deletions optional-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
xgboost==0.90
scikit-mdr==0.4.4
skrebate==0.3.4
torch==1.3.1
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ update-checker>=0.16
stopit>=1.1.2
pandas>=0.24.2
joblib>=0.13.2
torch==1.3.1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def calculate_version():
'dask': ['dask>=0.18.2',
'distributed>=1.22.1',
'dask-ml>=1.0.0'],
'torch': ['torch==1.3.1'],
},
classifiers=[
'Intended Audience :: Science/Research',
Expand Down
2 changes: 1 addition & 1 deletion tpot/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"""

__version__ = '0.11.4'
__version__ = '0.11.5'
6 changes: 5 additions & 1 deletion tpot/builtins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
from .one_hot_encoder import OneHotEncoder, auto_select_categorical_features, _transform_selected
from .feature_transformers import CategoricalSelector, ContinuousSelector
from .feature_set_selector import FeatureSetSelector
from .nn import PytorchLRClassifier, PytorchMLPClassifier
try:
from .nn import PytorchLRClassifier, PytorchMLPClassifier
except (ModuleNotFoundError, ImportError):
import warnings
warnings.warn("Warning: optional dependency `torch` is not available. - skipping import of NN models.")
21 changes: 12 additions & 9 deletions tpot/builtins/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@
from sklearn.utils.validation import check_X_y, assert_all_finite, check_array, check_is_fitted
from sklearn.utils.multiclass import type_of_target

import torch
from torch import nn
from torch.autograd import Variable
from torch.optim import Adam
from torch.utils.data import TensorDataset, DataLoader
try:
import torch
from torch import nn
from torch.autograd import Variable
from torch.optim import Adam
from torch.utils.data import TensorDataset, DataLoader
except ModuleNotFoundError:
raise

def _pytorch_model_is_fully_initialized(clf: BaseEstimator):
if all([
hasattr(clf, 'network'),
hasattr(clf, 'loss_function'),
hasattr(clf, 'optimizer'),
hasattr(clf, 'data_loader'),
hasattr(clf, 'data_loader'),
hasattr(clf, 'train_dset_len'),
hasattr(clf, 'device')
]):
Expand Down Expand Up @@ -100,15 +103,15 @@ def _init_model(self, X, y): # pragma: no cover
def fit(self, X, y):
"""Generalizable method for fitting a PyTorch estimator to a training
set.
Parameters
----------
X : array-like of shape (n_samples, n_features)
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like of shape (n_samples,)
Target vector relative to X.
Returns
-------
self
Expand Down Expand Up @@ -243,7 +246,7 @@ def __init__(
self.learning_rate = learning_rate
self.weight_decay = weight_decay
self.verbose = verbose

self.input_size = None
self.num_classes = None
self.network = None
Expand Down

0 comments on commit 1c009c6

Please sign in to comment.