clab/dynet

Is there any way to do discrete masking?

Open

#1,438 opened on 2018年9月1日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)C++ (701 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (3,433 stars)
PR merge metrics
 (PR metrics pending)

説明

I would like to implement a discrete mask like the following one in numpy.

import numpy
a = numpy.array([0., 2.])
a = 1/a
a # array([inf, 0.5])
b = numpy.array([True, False])
a[b] = 0
a # array([0. , 0.5])

If we use an ordinary mask implementation, for example, setting b = input(cg, {2}, {0., 1.}); and a = cmult(a, b); // a is an Expression just like the one in 4th line of the code block above, then nan values would appear. The reason is that 0 * inf is always indetermined.

Could we implement such discrete masks on top of current dynet or it is a missing feature?

コントリビューターガイド