Skip to content

Instantly share code, notes, and snippets.

View unnonouno's full-sized avatar

Yuya Unno unnonouno

View GitHub Profile
digits = Capture(r"\d+", int)
date = Seq(
(digits, "/", digits, "/", digits),
lambda year, _1, month, _2, day: datetime.date(year, month, day),
)
date_time = Seq(
(digits, "/", digits, "/", digits, " ", digits, ":", digits),
lambda year, _1, month, _2, day, _3, hour, _4, minute: datetime.datetime(year, month, day, hour, minute),
)
span = Seq(((date | date_time), "-", (date | date_time)), lambda begin, _, end: (begin, end))
import cupy as xp
import cupy.prof
import chainer
from chainer.functions.activation import lstm
B = 1024
D = 2048
x_shape = (B, D * 4)
c_shape = (B, D)
@unnonouno
unnonouno / npz_keys.py
Created April 19, 2017 13:51
npz_keys.py
import sys
import numpy
if __name__ == '__main__':
with numpy.load(sys.argv[1]) as f:
print(f.keys())
@unnonouno
unnonouno / fuse_result.png
Last active October 7, 2022 02:39
cupy.fuse example
fuse_result.png
@unnonouno
unnonouno / cudnn_bench.py
Last active March 1, 2017 02:41
cuDNN benchmark
import contextlib
import time
import chainer
import chainer.functions as F
import cupy
@contextlib.contextmanager
def timer(message):
import numpy
import chainer
import chainer.functions as F
import chainer.links as L
class LongChain(chainer.Chain):
def __init__(self):
super(LongChain, self).__init__()
def StatefullRNNUnit(chainer.Chain):
def StatefullRNNUnit(self, rnn):
self.rnn = rnn
self.state = (None,) * rnn.n_state
def __call__(x):
args = self.state + (x,)
ret = self.rnn(*args)
self.state = ret[:-1]
return ret[-1]
import chainer
from chainer import cuda
import cupy
import numpy
import time
ls = numpy.random.randint(1, 100, size=1000)
ls = numpy.sort(ls)[::-1]
unit = 100
xs = [cupy.empty((l, unit), 'f') for l in ls]
@unnonouno
unnonouno / cpugpu.py
Created July 5, 2016 08:31
Mixing CPU/GPU parameters in one Chainer model
import chainer
from chainer import cuda
import chainer.functions as F
import chainer.links as L
import chainer.optimizers as O
import cupy
import numpy
class MyModel(chainer.Chain):
@unnonouno
unnonouno / gist:602cfb7b2a7482c0cd6fa56121c5f502
Last active May 9, 2016 09:34
Chainer改善しやすいissue一覧
  • ドキュメントの品質改善
    • ドキュメントのクオリティーを上げてください。現状のドキュメントは必ずしも品質が良いとはいえません。読みやすい英語、詳細な仕様など、改善点はたくさんあります。
  • CuPyの関数充実
    • 606, 602, 677, 701
    • CuPyの関数はNumPyの一部しか実装されていません。elementwiseやreductionでかける関数は、比較的低コストで実装できます
  • テスト充実
    • 569, 568
    • 一部のモジュールはテストがかけています。テストの充実は品質向上に役立つ上に、コードの理解につながります
  • Chainer.functionsの追加
  • 1160, 1133, 1085, 1027, 945