Thursday, March 21, 2019

[AutoKeras] My first try with a simple example of AutoKeras

AutoKeras only supports Python 3.6 so that the running environment has to install Python 3.6. My operation system is Ubuntu 16.04 and it needs to add apt repository first.

Install Python 3.6 and AutoKeras ( Don't remove Python 3.5)
# Install pip3
apt-get install python3-pip
# Install Python 3.6
apt-get install software-properties-common
add-apt-repository ppa:jonathonf/python-3.6
apt-get update
apt-get install python3.6

update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
update-alternatives --config python3

ln -s /usr/include/python3.5 /usr/include/python3.6m
pip3 install lws
pip3 install autokeras

[Option] for install autokeras using pip instead of pip3:
# pip is bundled with Python > 3.4
# On Unix-like systems use:
python3.6 -m pip install autokeras

Try a simple MNIST example in AutoKeras' examples and it takes around 1.5 hours in my case ( I have two GTX 1080 cards)
This example will find a model having 99.64% accuracy.
/danny/autokeras/examples/a_simple_example# python3 mnist.py

+----------------------------------------------+
|               Training model 0               |
+----------------------------------------------+
No loss decrease after 5 epochs.


Saving model.
+--------------------------------------------------------------------------+
|        Model ID        |          Loss          |      Metric Value      |
+--------------------------------------------------------------------------+
|           0            |  0.15967900454998016   |          0.99          |
+--------------------------------------------------------------------------+


+----------------------------------------------+
|               Training model 1               |
+----------------------------------------------+
No loss decrease after 5 epochs.


Saving model.
+--------------------------------------------------------------------------+
|        Model ID        |          Loss          |      Metric Value      |
+--------------------------------------------------------------------------+
|           1            |  0.12146810069680214   |   0.9908000000000001   |
+--------------------------------------------------------------------------+


+----------------------------------------------+
|               Training model 2               |
+----------------------------------------------+
No loss decrease after 30 epochs.

==> The final accuracy it gets:
99.64

Without any GPU configuration, it will use all of your GPUs in the environment as follows:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 387.26                 Driver Version: 387.26                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:05:00.0 Off |                  N/A |
| 46%   67C    P2   119W / 198W |   1852MiB /  8112MiB |     70%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 1080    Off  | 00000000:0A:00.0 Off |                  N/A |
| 49%   69C    P2    83W / 198W |   1208MiB /  8114MiB |     66%      Default |
+-------------------------------+----------------------+----------------------+

No comments: