Skip to content

Instantly share code, notes, and snippets.

@X4
Created March 6, 2017 21:54
Show Gist options
  • Save X4/f5f71edcbaf5a0c969fba48589878b0a to your computer and use it in GitHub Desktop.
Save X4/f5f71edcbaf5a0c969fba48589878b0a to your computer and use it in GitHub Desktop.
# Performs a beam search, to be run in the "Decoder"
def Beamsearch(self,
predict_fun, # RNN() with: new_states as a list, outputs of shape (batch_size, n_symbols)
states0, # RNN()'s initial layer states are equal to states0
batch_size, # Size derived from initial layer states0
start_symbol # Tagging the encoded target sequence with <S> as a start symbol for example
stop_symbol # ' ' </S> as a stop symbol for example
max_length, # Maximum length of a given sequence
beam_size=4 # See [simple beam search](https://github.com/SeitaroShinagawa/simple_beamsearch) for an example of probabilities
):
return (sequence, mask, scores)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment