clab/dynet

Is there any way to do discrete masking?

Open

#1.438 aberto em 1 de set. de 2018

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)C++ (701 forks)github user discovery
enhancementhelp wanted

Métricas do repositório

Stars
 (3.433 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

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?

Guia do colaborador