Pylearn2 インストール方法
LinuxへのPylearn2のインストール方法。(対象はubuntu)
1. python、git、pipのインストール
aptデータベースの更新
sudo apt-get update
gitをインストール
sudo apt-get install -y --force-yes git
pythonをインストール
sudo apt-get install -y --force-yes python
2. Python各種パッケージのインストール
開発系パッケージ、matplot(plot用)、NumPy(数値計算)、SciPy(科学技術計算)、などをインストール。
sudo apt-get install -y --force-yes python-all-dev libblas-dev libblas3 liblapack-dev liblapack3 liblapacke liblapacke-dev python-matplotlib python-matplotlib-data sudo apt-get install -y --force-yes python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
3. Python Imaging Library (PIL) のインストール
PILは画像データを扱うためのpythonライブラリ。
sudo apt-get install python-dev libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev sudo apt-get build-dep python-imaging pip install git+git://github.com/python-imaging/Pillow.git
4. その他のパッケージをpipでインストール
theano(数値計算用ライブラリ)、PyYAML、など。
sudo pip install theano sudo pip install PyYAML sudo pip uninstall pydot pyparsing sudo pip install pyparsing==1.5.7 sudo pip install pydot
5. pylearn2本体のインストール
git clone git://github.com/lisa-lab/pylearn2.git cd pylearn2 # sudo python setup.py install # /usr/ にインストールする場合 python setup.py install --home=~ # 自分のホームディレクトリにインストールする場合
6. PATHの設定
cp ~/.bashrc ~/.bashrc_bak echo export PYLEARN2_DATA_PATH=$cwd/data >> ~/.bashrc echo export PATH=$cwd/pylearn2/pylearn2/scripts:$PATH >> ~/.bashrc # TODO: escape "$PATH" as raw string echo export PYLEARN2_VIEWER_COMMAND="eog --new-instance" >> ~/.bashrc
7. チュートリアル用データのダウンロード
cifar10。画像クラスのデータセット。
cd data mkdir cifar10 cd cifar10 wget http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz tar xvfz cifar-10-python.tar.gz
ここまで設定するとcifar10を使ったチュートリアルが動く。
CIFER-10のチュートリアル
$ cd ~/pylearn2/pylearn2/scripts/tutorials/grbm_smd $ python make_dataset.py (実行済み) $ train.py cifar_grbm_smd.yaml # 学習 (2分ほどかかる) $ show_weights.py --out=weights.png cifar_grbm_smd.pkl $ print_monitor.py cifar_grbm_smd.pkl
cifer10
学習結果(隠れ層ユニット数=30)