Skip to content

Instantly share code, notes, and snippets.

@shshemi
Last active March 27, 2020 14:29
Show Gist options
  • Save shshemi/3169b5efe61e20d8c4bae75465bf1c21 to your computer and use it in GitHub Desktop.
Save shshemi/3169b5efe61e20d8c4bae75465bf1c21 to your computer and use it in GitHub Desktop.
def ascii_encode(message, sentence_len):
sen = np.zeros((1, sentence_len))
for i, a in enumerate(message.encode("ascii")):
sen[0, i] = a
return sen
def ascii_decode(message):
return ''.join(chr(int(a)) for a in message[0].argmax(-1))
Copy link

ghost commented Mar 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment