clab/dynet

Is there any way to do discrete masking?

Open

#1,438 建立於 2018年9月1日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C++ (701 fork)github user discovery
enhancementhelp wanted

倉庫指標

Star
 (3,433 star)
PR 合併指標
 (PR 指標待抓取)

描述

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?

貢獻者指南