tf-seq2seq icon indicating copy to clipboard operation
tf-seq2seq copied to clipboard

Get error when initializing decoder initial state

Open seanie12 opened this issue 7 years ago • 4 comments

In seq2seq_model.py file, I use bi-directional GRU for encoder but I got an error. More specifically,in line 391, i got an error as follows

"TypeError: Tensor objects are not iterable when eager execution is not enabled. To iterate over this tensor use tf.map_fn."

I use tensorflow 1.7 How can I solve this problem?

In addition, why do have to initialize last decoder cell to zero state not encoder last state as preceding layer?

Thanks in advance

seanie12 avatar May 09 '18 11:05 seanie12

I found out a solution Instead of using list comprehension, use for loop to append every encoder state to new list and make it tuple. Here is my suggestion if you want to use bi-directional rnn for encoder part

    init_state = []
    for i in range(self.num_layers):
        init_state.append(encoder_last_states[i])
    init_state[-1] = decoder_cell_list[-1].zero_state(batch_size,
                                                      dtype=tf.float32)
    decoder_init_state = tuple(init_state)

seanie12 avatar May 10 '18 01:05 seanie12

unsupported operand type(s) for -: 'float' and 'Flag' hey @seanie12 can you please help me with this issue? this issue is coming when i am running the train.py file.. screen shot 2018-05-27 at 19 55 49

jigyasa06 avatar May 27 '18 18:05 jigyasa06

@jigyasa06 sorry i don't know how to solve .. maybe @JayParks might help

seanie12 avatar May 28 '18 11:05 seanie12

hey @JayParks can you please see to this problem?

jigyasa06 avatar May 29 '18 14:05 jigyasa06