7. デバッグモード
chainer.set_device(True)で使えます
NaNの検出デモ
In [1]: import chainer, numpy
In [2]: chainer.set_debug(True)
In [3]: x = chainer.Variable(numpuy.array([float(‘nan’)], ’f’))
In [4]: chainer.functions.identity(x)
-----------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-e234ae95dfb6> in <module>()
----> 1 chainer.functions.identity(x)
=========省略=========
RuntimeError: NaN is detected on forward computation
7/18
8. ファンクションフック
例えば時間を測るフックが作れます:TimerHook
In [1]: import chainer, chainer.function_hooks, numpy
In [2]: h = chainer.function_hooks.TimerHook()
In [3]: link = chainer.links.Linear(5, 5)
In [4]: with h:
...: link(chainer.Variable(numpy.zeros((3, 5), 'f')))
...:
In [5]: print(h.total_time())
0.011421918869
In [6]: print(h.call_history)
[(<chainer.functions.connection.linear.LinearFunction object
at 0x7fb18d9ff790>, 0.011421918869018555)]
8/18
9. Variable.debug_print
debug_print()を呼ぶだけ
In [1]: import chainer, numpy
In [2]: d = numpy.random.uniform(-1, 1, (3, 5)).astype('f')
In [3]: x = chainer.Variable(d)
In [4]: print(x.debug_print())
<variable at 0x7fac1017a790>
- device: CPU
- volatile: OFF
- backend: <type 'numpy.ndarray'>
- shape: (3, 5)
- dtype: float32
- statistics: mean=-0.02048243, std=0.46310186
- grad: None
9/18
10. 新しい関数(Chainer)その1
activation
elu (#754)
log_softmax (#842)
maxout (#856)
slstm (#518)
LSTM along binary trees
array
broadcast_to (#826)
expand_dims (#690)
evaluation
binary_accuracy (#757)
Accuracy for binary classification.
10/18
11. 新しい関数(Chainer)その2
math
batch_l2_norm_squared (#828)
det, batch_det (#613)
matrix determinant
inv, batch_inv (#608)
Differentiable matrix inversion
pool
unpooling_2d(#599)
spatial upsampling
Link
StatefulGRU (#817)
GRU with LSTM chain-like interface
Maxout (#856)
11/18