$ pip install --upgrade pip
$ pip install chainer
chainer/chainerからサンプルをダウンロード
$ brew tap caskroom/cask
機械学習のHello-World「train_mnist.py 」を動かしてみる。 *初回時は画像素材をダウンロード *デフォルト設定だと20回学習
$ python3 train_mnist.py
GPU: -1
# unit: 1000
# Minibatch-size: 100
# epoch: 20
Downloading from http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz...
Downloading from http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz...
Downloading from http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz...
Downloading from http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz...
epoch main/loss validation/main/loss main/accuracy validation/main/accuracy elapsed_time
1 0.191203 0.107441 0.942 0.9668 20.6231
2 0.0746089 0.0724309 0.9769 0.9779 43.3326
3 0.0483745 0.0715516 0.9848 0.9798 66.719
4 0.0341754 0.0789327 0.988833 0.9795 89.0281
5 0.0292061 0.0925641 0.9908 0.9752 109.421
6 0.0256707 0.0715148 0.991683 0.9806 132.37
7 0.0188833 0.0750383 0.993767 0.9808 153.467
8 0.0178651 0.0916148 0.993967 0.9798 173.683
9 0.0190301 0.0876899 0.9941 0.9805 194.203
10 0.0147034 0.0869119 0.995183 0.9813 217.873
11 0.0140121 0.088435 0.995817 0.9802 242.648
12 0.0151053 0.0939939 0.99495 0.9823 268.818
13 0.0103742 0.0957632 0.996717 0.9829 292.792
14 0.00854318 0.0905123 0.997467 0.9821 317.834
15 0.00866289 0.118263 0.99745 0.9766 343.89
16 0.0151463 0.0986677 0.99545 0.9817 368.499
17 0.00866498 0.0853589 0.99735 0.9842 395.06
18 0.00716674 0.131718 0.997883 0.9776 421.821
19 0.00858464 0.111747 0.997567 0.9834 448.749
20 0.0127154 0.103087 0.996683 0.9814 474.769
運よくNVIDIA製のグラボを積んだマシンを持っていたらGPUモードで計算させられます。 (自分は持ってない・・・) NVIDIAからCUDAダウンロード
$ brew tap homebrew/science
$ brew install opencv3 --with-contrib --with-python3 --without-python
$ vi .bashrc
export PATH=/Developer/NVIDIA/CUDA-8.0/bin:$PATH
export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-7.5/lib:$DYLD_LIBRARY_PATH
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
$ ln -s /usr/local/Cellar/opencv3/3.2.0/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so ~/.pyenv/versions/3.6.1/lib/python3.6/site-packages/
$ ln -s /usr/local/Cellar/opencv3/3.2.0/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so ~/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/
$ python
>>import cv2
>>