[GAN], [Text] Generator generates padding symbol

Sorry for being vague in the title, for me the issue is too complicated to put it into simpler words. Bare with me until I explain the back story first.

I have a GAN to generate text, both the generator and the discriminator are LSTMs. I am trying to learn SeqGAN therefore most of my code is based on this repository.

I am using pack_paded_sequences to input sequences to the Generator. Since i need to calculate the lengths of all sequences in the batch in order to pack them I use the following logic to calculate the length

len(seq[seq!=padding_symbol])

If a given sequence only has padding symbol then the length obviously will be zero. And we cannot use the function to pack the sequences then.

Since this is a Text generation and based on SeqGAN i am using Policy Gradients to calculate the reward for a complete sequence. To calculate the reward for an incomplete sequence, they have used monte carlo search to fill up the unknown tokens.

Monte Carlo search

How they have set that up is that, first the generator will be sampled and parts of the sequence will be sent to the monte carlo search function to get the tokens and using that completed samples we calculate the reward for that part of the sequence.

So the issue is that the generator sometimes generates a padding symbol at the front of the sequence, and when we calculate the reward for the first token, it will raise the following run time error.

Length of all samples has to be greater than 0, but found an element in 'lengths' that is <= 0

How would you stop the generator from generating the EOS symbol because thats what I have used as my padding symbol.