clab / clab/dynet

Is there any way to do discrete masking?

Open
#1,438 2 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
C++
Stars
3.4k
Forks
701
PR merge metrics
No merged PRs in 30d

Description

I would like to implement a discrete mask like the following one in numpy.
```python
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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the current DyNet paths for input and cmult mentioned in the issue, and compare their behavior with the NumPy example. Determine how a discrete mask could avoid evaluating the masked 0 * inf operation; done means the mask produces the intended values without nan in this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, numpy
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.