- 将棋AIで学ぶディープラーニング (山岡忠夫著) の手法を参考にする。 [1]
- 個人で利用するのが現実的な学習リソースとコストで、ディープラーニングモデルを強くするため、Google Colab を積極的に活用する。
将棋以外にも活用するため、 Python を利用する。高速化が見込まれる場合は、 Cython を利用する。- 対局時の高速化のために、dlshogi (Pytorch/TensorRT) を利用する。
- 学習時の高速化のために、dlshogi (Pytorch) を利用する。
Google の AlphaZero の手法をリスペクトするため、Google Colab (GCP) の TPU を利用する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to check if the script is running as Administrator | |
function Test-IsAdmin { | |
$currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
} | |
# If not running as Administrator, restart the script with elevated privileges | |
if (-not (Test-IsAdmin)) { | |
Write-Output "Restarting script with elevated privileges..." | |
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If `unsafe` and `nightly` are enabled, enable unstable `core_intrinsics` feature | |
// with #![feature(core_intrinsics)] (Nightly only). | |
macro_rules! invariant { | |
($expr: expr) => { | |
cfg_if::cfg_if! { | |
if #[cfg(all(feature = "unsafe", feature = "nightly"))] { | |
core::intrinsics::assume($expr); | |
} | |
else if #[cfg(feature = "unsafe")] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import zlib | |
from typing import BinaryIO, List, Tuple | |
Pixel = Tuple[int, int, int] | |
Image = List[List[Pixel]] | |
BLACK_PIXEL: Pixel = (0, 0, 0) | |
WHITE_PIXEL: Pixel = (255, 255, 255) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EloRating Calculator | |
// http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html | |
pub fn gammaln_6(x: f64) -> f64 { | |
// 0 < x < infinity | |
// err = 2.09144255e-18 | |
(x - 0.5) * (x + 6.0975075753906857609437558e+0).ln() - x | |
+ ((((((1.1240582657165407383437999e-2 / (x + 5.0003589884831925541613237e+0) | |
+ 5.0219722703392090725884168e-1) | |
/ (x + 3.9999966300007508932097016e+0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map print, | |
map "hello = $_->[0] , world = $_->[1]\n", | |
map [split ','], | |
map {s/[\x0d\x0a]//g; $_} | |
map scalar <STDIN>, | |
1..<STDIN>; |