clab/dynet

Is there any way to do discrete masking?

Open

#1438 aperta il 1 set 2018

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)C++ (701 fork)github user discovery
enhancementhelp wanted

Metriche repository

Star
 (3433 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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?

Guida contributor