clab / clab/dynet

Can't set_h or set_s in an RNNState

Open
#782 2 comments 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

Hello,
I'm using dynet and maybe I've not understood something but I don't get why this code gives me an error:
```
from dynet import *

model = Model()
lstm_builder = FastLSTMBuilder(2, 3, 4, model)
s0 = lstm_builder.initial_state()
cell_state1 = [1, 3, 5, 6]
cell_state2 = [2, 4, 5, 6]
h_state1 = [5, 6, 9, 3]
h_state2 = [3, 6, 8, 8]
cell_state1 = inputVector(cell_state1)
cell_state2 = inputVector(cell_state2)
h_state1 = inputVector(h_state1)
h_state2 = inputVector(h_state2)
s0.set_s([cell_state1, cell_state2, h_state1, h_state2])
```
I get:
> terminate called after throwing an instance of 'std::invalid_argument'
> what(): FastLSTMBuilder::set_s expects as many inputs or twice as many inputs as layers, but got 4 inputs for 2 layers

>Process Python aborted (core dumped)

I get a similar error with set_h()

I don't know what my mistake is...
It seems to work with LSTMBuilder though

Moreover if I `set s0.set_s([cell_state1, cell_state2, h_state1, h_state2])` and then
`print s0.s()[0].value()`
Aren't I supposed to get [1, 3, 5, 6] (using LSTMBuilder) ? (cell_state1)
Because it's not the case.

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.