clab / clab/dynet

Vector vs. column matrix, example with dot_product

Open
#1,343 1 comment 0 reactions 0 assignees View on GitHub
moderate bug
Dominant language
C++
Stars
3.4k
Forks
701
PR merge metrics
No merged PRs in 30d

Description

Hi,

is there any reason why vectors are different from vector matrices?
For example, for the dot_product function, if only one of the parameters has a number of colums (equal to one), the operation fails.
For example, dot_product(e1, e2) with:
- e1.dim = {3}, e2.dim = {3}: OK
- e1.dim = {3,1}, e2.dim = {3,1}: OK
- e1.dim = {3,1}, e2.dim = {3}: Error
- e1.dim = {3}, e2.dim = {3,1}: Error

```
1 #include "dynet/expr.h"
2
3 int main(int argc, char* argv[])
4 {
5 dynet::initialize(argc, argv);
6 auto size = 3u;
7
8 dynet::ParameterCollection pc;
9 auto p1 = pc.add_parameters({size,1});
10 auto p2 = pc.add_parameters({size});
11
12 dynet::ComputationGraph cg;
13 auto e1 = dynet::parameter(cg, p1);
14 // solution, but documentation says that is a constant time operation only for forward
15 //e1 = dynet::reshape(e1, {size});
16 auto e2 = dynet::parameter(cg, p2);
17 auto dot = dynet::dot_product(e1, e2);
18
19 cg.forward(dot);
20 }
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with dynet/expr.h and the dot_product entry point, then reproduce the four tensor-shape combinations in the issue's C++ example. Trace how vector and {size,1} shapes are validated and check nearby tests for shape compatibility. Done should establish and implement the intended behavior, or clarify the documented restriction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Bug
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.