Skip to content

Instantly share code, notes, and snippets.

Avatar

Yuya Unno unnonouno

View GitHub Profile
View gist:9ae67c92f71300df3ab980f610aef712
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))
View lstm_test.py
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)
View npz_keys.py
import sys
import numpy
if __name__ == '__main__':
with numpy.load(sys.argv[1]) as f:
print(f.keys())
@unnonouno
unnonouno / cudnn_bench.py
Last active Mar 1, 2017
cuDNN benchmark
View cudnn_bench.py
import contextlib
import time
import chainer
import chainer.functions as F
import cupy
@contextlib.contextmanager
def timer(message):
View forget_example.py
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__()
View rnn.py
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]
View trans_test.py
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 Jul 5, 2016
Mixing CPU/GPU parameters in one Chainer model
View cpugpu.py
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
Chainer改善しやすいissue一覧
View gist:602cfb7b2a7482c0cd6fa56121c5f502
  • ドキュメントの品質改善
    • ドキュメントのクオリティーを上げてください。現状のドキュメントは必ずしも品質が良いとはいえません。読みやすい英語、詳細な仕様など、改善点はたくさんあります。
  • CuPyの関数充実
    • 606, 602, 677, 701
    • CuPyの関数はNumPyの一部しか実装されていません。elementwiseやreductionでかける関数は、比較的低コストで実装できます
  • テスト充実
    • 569, 568
    • 一部のモジュールはテストがかけています。テストの充実は品質向上に役立つ上に、コードの理解につながります
  • Chainer.functionsの追加
    • 1160, 1133, 1085, 1027, 945