udibr / headlines

Automatically generate headlines to short articles
MIT License
525 stars 150 forks source link

beamsearch(): index 0 is out of bounds for axis 1 with size 0? #17

Open saitaiky opened 7 years ago

saitaiky commented 7 years ago

The network can train smoothly by calling gensamples(batch_size=batch_size) , but I am just wodering why the function beamsearch() doesn't work when it is called from this line

gensamples(skips=2, batch_size=batch_size, k=10, temperature=1.)

def beamsearch(): ... cand_scores[:,empty] = 1e20 ...

The error is IndexError: index 0 is out of bounds for axis 1 with size 0. I am new in ML, could you please give me some advice to fix it? thank you

imranshaikmuma commented 7 years ago

are you using python3?

if so change the statement sample_lengths = map(len, samples) in keras_rnn_predict function as below: sample_lengths = list(map(len, samples))

JC-B commented 7 years ago

Thank you. This was helpful.