Installation
The core package, colearn
, contains only the MachineLearningInterface and a simple driver that
implements the Collective Learning Protocol.
To install only the core package:
pip install colearn
To make collective learning easier to use we have defined extra packages with helpers for model development in Keras and Pytorch.
To install with Keras/Pytorch extras:
pip install colearn[keras]
pip install colearn[pytorch]
To install both the Keras and Pytorch extras use:
pip install colearn[all]
To run stand-alone examples:
# Download the examples
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/keras_cifar.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/keras_fraud.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/keras_mnist.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/keras_mnist_diffpriv.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/keras_xray.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/mli_fraud.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/mli_random_forest_iris.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/pytorch_cifar.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/pytorch_covid.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/pytorch_mnist.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/pytorch_mnist_diffpriv.py
wget https://raw.githubusercontent.com/fetchai/colearn/master/examples/pytorch_xray.py
# Or they can be accessed from colearn/examples by cloning colearn repo
# for colearn[keras] or colearn[all]
python3 keras_mnist.py
# for colearn[pytorch] or colearn[all]
python3 pytorch_mnist.py
Installing From Source
Alternatively, to install the latest code from the repo:
- Download the source code from github:
git clone https://github.com/fetchai/colearn.git && cd colearn
-
Create and launch a clean virtual environment with Python 3.7. (This library has currently only been tested with Python 3.7).
pipenv --python 3.7 && pipenv shell
-
Install the package from source:
pip install -e .[all]
- Run one of the examples:
examples/pytorch_mnist.py
If you are developing the colearn library then install it in editable mode so that new changes are effective immediately:
pip install -e .[all]
Running the tests
Tests can be run with:
tox
Documentation
To run the documentation, first install mkdocs and plugins:
pip install .[docs]
Then run:
mkdocs serve