Better Interface/Examples for TreeRNNBuilders (was: How to use UnidirectionalTreeLSTMBuilder in dynet ?)
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 701
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to build an buttom-up TreeLSTM using dynet with `UnidirectionalTreeLSTMBuilder` in `treelstm.cc`, however I can't understand how to call the `UnidirectionalTreeLSTMBuilder::add_input function`, and it seems that there are no examples.
The `TheirTreeLSTMBuilder::add_input` in https://github.com/clab/dynet/blob/dynamictreelstms/cnn/theirtreelstm.cc#L121 is comprehensible, the thing I don't understand about the new version is that it uses a LSTMBuilder to implement the structure, but I didn't see how can LSTM combine more than one input from different children.
So could anyone give an example about how to call this `UnidirectionalTreeLSTMBuilder::add_input` function ?
```
UnidirectionalTreeLSTMBuilder::add_input(int id, vector children, const Expression& x) {
assert (id >= 0 && h.size() == (unsigned)id);
RNNPointer prev = (RNNPointer)(-1);
Expression embedding = node_builder.add_input(prev, x);
prev = node_builder.state();
for (unsigned child : children) {
embedding = node_builder.add_input(prev, h[child]);
prev = node_builder.state();
}
h.push_back(embedding);
return embedding;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with treelstm.cc and compare UnidirectionalTreeLSTMBuilder::add_input with cnn/theirtreelstm.cc around the referenced example. Clarify or document how child states are passed to add_input and how the LSTMBuilder combines them; done means a newcomer can follow a concrete usage example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- machine-learning
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100