clab / clab/dynet

Why does ParameterNode contains an extra "Dim"?

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

Description

ParameterNode is derived from ParameterNodeBase, which is derived from Node. There is a member dim in Node, so why does the ParameterNode contains another dim?

struct Node {
// ...
Dim dim;
};

struct ParameterNodeBase : public Node {
virtual void accumulate_grad(const Tensor& g) = 0;
};

struct ParameterNode : public ParameterNodeBase {
// ...
Dim dim;
};

The following is the test code:

int main(int argc, char** argv) {
dynet::initialize(argc, argv);

// ParameterCollection (all the model parameters).
ParameterCollection m;
Parameter p_W = m.add_parameters({8, 2});

dynet::ParameterNode pn(p_W);
cout << pn.dim << endl; // output {8, 2}
Node* p = &pn;
cout << p->dim << endl; // output {}
}

Is that what we want to see?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.