Slice error when using MultiRNNCell
I've got a problem similar to yours.{tensorflow.python.framework.errors.InvalidArgumentError: Expected size[1] in [0, 0], but got 40}
I also use rnn_cell.GRUCell(self.rnn_size)
I want to share my experience ,maybe it's helpful.
Here is how I fixed it.
I want to use gru cell and basic rnn cell ,so I adapt the programme from others which is coded for lstm cell.
The different between lstm and GRU/BasicRnn is the state_size.
Here is lstm celldef state_size(self):return 2 * self._num_units
Here is GRU/BasicRnn cell def state_size(self):return self._num_units
Therefore the shape of matrix is different,and the tensor is not suit for the op.I advice you to check your code contains tf.slice
I am using MultiRNNCell from tensorflow.models.rnn.rnn_cell. This is how declare my MultiRNNCell
Code:
e_cell = rnn_cell.GRUCell(self.rnn_size)
e_cell = rnn_cell.MultiRNNCell([e_cell] * 2)
Later on I use it from inside seq2seq.embedding_rnn_decoder as follows
ouputs, mem_states = seq2seq.embedding_rnn_decoder(decoder_inputs, enc_state, e_cell, vocab_size, output_projection=(W, b), feed_previous=False)#
On doing this I get the following error
Error:
tensorflow.python.framework.errors.InvalidArgumentError: Expected size[1] in [0, 0], but got 1024
         [[Node: en/embedding_rnn_decoder_1/rnn_decoder/MultiRNNCell/Cell1/Slice = Slice[Index=DT_INT32, T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](Sigmoid_2, en/embedding_rnn_decoder_1/rnn_decoder/MultiRNNCell/Cell1/Slice/begin, en/embedding_rnn_decoder_1/rnn_decoder/MultiRNNCell/Cell1/Slice/size)]]
         [[Node: en/embedding_rnn_decoder/rnn_decoder/loop_function_17/StopGradient/_1230 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_11541_en/embedding_rnn_decoder/rnn_decoder/loop_function_17/StopGradient", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Has anyone seen a similar error? Any pointers?