From 141335d6791fde36e7ee5804e3cd8e975c912330 Mon Sep 17 00:00:00 2001 From: sakoda Date: Sun, 4 Apr 2021 11:23:32 +0900 Subject: [PATCH] =?UTF-8?q?README.md=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NOTICE | 75 ------------------------------------------------------- README.md | 53 +++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 102 deletions(-) delete mode 100644 NOTICE diff --git a/NOTICE b/NOTICE deleted file mode 100644 index 91073bd2..00000000 --- a/NOTICE +++ /dev/null @@ -1,75 +0,0 @@ -This program use PyTorch. PyTorch is licensed under the BSD license. -The copyright and license terms are shown below. - -From PyTorch: - -Copyright (c) 2016- Facebook, Inc (Adam Paszke) -Copyright (c) 2014- Facebook, Inc (Soumith Chintala) -Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) -Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) -Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) -Copyright (c) 2011-2013 NYU (Clement Farabet) -Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) -Copyright (c) 2006 Idiap Research Institute (Samy Bengio) -Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) - - -From Caffe2: - -Copyright (c) 2016-present, Facebook Inc. All rights reserved. - -All contributions by Facebook: -Copyright (c) 2016 Facebook Inc. - -All contributions by Google: -Copyright (c) 2015 Google Inc. -All rights reserved. - -All contributions by Yangqing Jia: -Copyright (c) 2015 Yangqing Jia -All rights reserved. - -All contributions from Caffe: -Copyright(c) 2013, 2014, 2015, the respective contributors -All rights reserved. - -All other contributions: -Copyright(c) 2015, 2016 the respective contributors -All rights reserved. - -Caffe2 uses a copyright model similar to Caffe: each contributor holds -copyright over their contributions to Caffe2. The project versioning records -all such contribution and copyright details. If a contributor wants to further -mark their specific copyright on a particular contribution, they should -indicate their copyright solely in the commit message of the change when it is -committed. - - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America - and IDIAP Research Institute nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index beaf96b5..46f0c9e1 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,42 @@ # Miacis + MiacisはUSIプロトコルに対応した将棋用思考エンジンです。[将棋所](http://shogidokoro.starfree.jp/)、[将棋GUI](http://shogigui.siganus.com/)などを用いて対局、検討を行うことができます。 -深層学習フレームワークとしてPyTorchを利用しています。PyTorchのライセンス規約はNOTICEに、Miacis自身のライセンスはLICENSEに記載しています。 +基本的に[AlphaZero](https://arxiv.org/abs/1712.01815)を模倣したものとなっており、深層強化学習を利用した評価関数を用いてモンテカルロ木探索を行います。 + +独自の工夫点として、評価値をスカラーではなくカテゴリカル分布を用いて出力します。これは[Categorical DQN](https://arxiv.org/abs/1707.06887)にヒントを得たものとなっています。 ## コンパイル方法 -コンパイル時にはPyTorchのC++APIである[LibTorch](https://pytorch.org/get-started/locally/)を必要とします。下例のようにスクリプトを使うなどしてMiacisと同階層にlibtorchを解凍しておくか、すでにダウンロード済みならばCMakeLists.txt9行目におけるlibtorchへのパスを適切に設定してください。 -Ubuntu18.04, CUDA10.0, cuDNN7.1, libtorch1.2(for CUDA10.0)の環境においてcmake3.10.2, g++7.4.0でビルドできることが確認できています。以下にLinuxでコンパイルする手順例を示します。 +コンパイルにはcmakeを利用します。ライブラリとして -``` -# Miacisの取得 -git clone https://github.com/SakodaShintaro/Miacis +* CUDA(cuDNN含む) +* LibTorch +* TensorRT +* TRTorch -# libtorchの取得(Miacisと同階層にlibtorchが解凍される) -Miacis/scripts/download_libtorch.sh +を必要とします。環境構築は複雑なのでDockerを利用することをお勧めします。 -# コンパイル -mkdir Miacis/src/cmake-build-release -cd Miacis/src/cmake-build-release -cmake .. -DCMAKE_BUILD_TYPE=Release -make -j4 -``` +## Dockerによる環境構築 -正常にコンパイルが進むと```cmake-build-release```以下に -* Miacis_shogi_scalar -* Miacis_shogi_categorical -* Miacis_othello_scalar -* Miacis_othello_categorical +Dockerおよび[NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)をインストールしてあるUbuntuを前提とします。 +以下に -というプログラムが得られます。```*_scalar```は評価値をスカラとして一つ出力するモデルであり、AlphaZeroとほぼ同等のモデルとなります。```*_categorical```は評価値の確率分布を出力するモデルとなります。 +1. Dockerfileをダウンロードする +2. miacis_trtorchというイメージをタグをpytorch1.7-cuda11.1-trt7.2.1として作成する +3. miacis_trtorchというイメージをもとにmiacis_containerという名前でコンテナを作成する -以前はWindows(Visual Studio2017にCMake拡張を入れた環境)でもコンパイル可能ではありましたが、現在可能であるかは未確認です。 +を行うコマンドを示します。適当な空のディレクトリ内で実行してください。 -## 対局方法 -USIオプションで指定するパスに評価関数パラメータを配置すると思考エンジンとして利用することができます。Miacis_scalarは```sca_bl10_ch128.model```というファイル、Miacis_categoricalは```cat_bl10_ch128.model```というファイルにPyTorchの定める形式でパラメータが格納されている必要があります。(bl10はブロック数が10であること、ch128はチャネル数が128であることを示しています。) +```shell +wget https://raw.githubusercontent.com/SakodaShintaro/Miacis/master/scripts/Dockerfile +docker build -t miacis_trtorch:pytorch1.7-cuda11.1-trt7.2.1 . +docker run --gpus all -it --name miacis_container miacis_trtorch:pytorch1.7-cuda11.1-trt7.2.1 bash +``` -## 学習方法 -MiacisはAlphaZeroと同様の形式による強化学習で評価関数パラメータの最適化を行うことができます。学習する際にはalphazero_settings.txtを実行プログラムと同ディレクトリに配置しパラメータ等を適切に設定してください。プログラムを実行して「alphaZero」と入力することで現在同ディレクトリに置かれている```cat(sca)_bl10_ch128.model```を初期パラメータとした学習が始まります。 +正常にコンパイルが進むとコンテナ内の```/root/Miacis/src/cmake-build-release```以下に```Miacis_shogi_categorical```というプログラムが得られます。 -プログラムを実行して「initParams」と入力するとランダムに初期化したパラメータが```cat(sca)_bl10_ch128.model```という名前で出力されます。同名のファイルがすでに存在している場合も上書きされるのでご注意ください。 +## 対局方法 -学習の際には```cat(sca)_bl10_ch128_before_alphazero.model```という名前で学習前のパラメータが保存されるため、誤って学習を行ってしまった場合はこれをリネームすることで学習前のパラメータに復帰することができます。 \ No newline at end of file +USIオプション```model_name```で指定するパスに評価関数パラメータを配置すると思考エンジンとして利用することができます。デフォルトでは```Miacis_shogi_categorical``` +と同じディレクトリに```shogi_cat_bl10_ch256.model```というファイルにパラメータが格納されている必要があります。(bl10はブロック数が10であること、ch256はチャネル数が256であることを示しています。) \ No newline at end of file