llSourcell / seq2seq_model_live

73 stars 63 forks source link

Encoder #5

Open ashgoodman opened 7 years ago

ashgoodman commented 7 years ago

The following throws an error, please update

((encoder_fw_outputs, encoder_bw_outputs), (encoder_fw_final_state, encoder_bw_final_state)) = ( tf.nn.bidirectional_dynamic_rnn(cell_fw=encoder_cell, cell_bw=encoder_cell, inputs=encoder_inputs_embedded, sequence_length=encoder_inputs_length, dtype=tf.float64, time_major=True)

Kaliostrogoblin commented 7 years ago

@ashgoodman, you should use variable scope initialization as follows:

with tf.variable_scope('encoder_cell', reuse=True): 
    encoder_cell = LSTMCell(encoder_hidden_dimension)

instead of presented one.

lofar788 commented 7 years ago

I changed the dtype to be tf.float32, it worked fine after that.

ketyi commented 7 years ago

None of the above fix this issue :/

lpsavalhais commented 7 years ago

@ketyi the same with me.. =/ Did you figure it out?

arthurtakaki commented 7 years ago

I would try to define the encoder as follows:

with tf.variable_scope('encoder_cell_fw'):
    encoder_cell_fw = LSTMCell(encoder_hidden_units)   
with tf.variable_scope('encoder_cell_bw'):
    encoder_cell_bw = LSTMCell(encoder_hidden_units) 

( (encoder_fw_outputs,
encoder_bw_outputs),
(encoder_fw_final_state,
encoder_bw_final_state)) = (
tf.nn.bidirectional_dynamic_rnn(cell_fw=encoder_cell_fw,
                            cell_bw=encoder_cell_bw,
                            inputs=encoder_inputs_embedded,
                            sequence_length=encoder_inputs_length,
                            dtype=tf.float32, time_major=False))
ruitedk6 commented 7 years ago

For me it (mysteriously) helped to put: with tf.variable_scope('encoder_cell', reuse=False): encoder_cell = LSTMCell(encoder_hidden_units) ((encoder_fw_outputs, encoder_bw_outputs), (encoder_fw_final_state, encoder_bw_final_state)) = ( tf.nn.bidirectional_dynamic_rnn(cell_fw=encoder_cell, cell_bw=encoder_cell, inputs=encoder_inputs_embedded, sequence_length=encoder_inputs_length, dtype=tf.float32, time_major=True) )

And then rerun all of the cells in the jupyter notebook.

suraz09 commented 6 years ago

Did it work for anyone? I am still facing the issue. Neither of the solution posted above helps.

My config is: Ubuntu 14.04 Tensorflow: 0.10.0

saurabhrathor commented 6 years ago

Changed scope for all. And time_major=False. Then executed complete code. TF version 1.2.1 It worked fine for me.

with tf.variable_scope('encoder_cell', reuse=True): encoder_cell = LSTMCell(encoder_hidden_units) with tf.variable_scope('encoder_cell_bw', reuse=True): encoder_cell_bw = LSTMCell(encoder_hidden_units) with tf.variable_scope('encoder_cell_fw', reuse=True): encoder_cell_fw = LSTMCell(encoder_hidden_units)

( (encoder_fw_outputs, encoder_bw_outputs), (encoder_fw_final_state, encoder_bw_final_state)) = ( tf.nn.bidirectional_dynamic_rnn(cell_fw=encoder_cell_fw, cell_bw=encoder_cell_bw, inputs=encoder_inputs_embedded, sequence_length=encoder_inputs_length, dtype=tf.float32, time_major=False))

SujoySust commented 6 years ago

My tensorflow version is 1.3.0 . Above these solves are not working in this version. Can anyone give me a solution please ?