Simple RNN Deciphers Code
Table of Contents
- Overview
- Pipeline
- Tokenization
- Padding
- Define RNN
- Postprocessing
- Output at Every Step
- Conclusion
Overview
In this article, we will define a simple RNN to decrypt a Caesar Cipher. If you’re not familiar with RNNs, take a look at RNN Numerical Walkthrough + Code.
Caesar Cipher
A Caesar Cipher is a cipher that encodes sentences by replacing the letters by other letters shifted by a fixed size. For example, a Caesar Cipher with a left shift value of 3 will result in the following:
Input: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
Notice that there is a 1-to-1 mapping for every character, where every input letter maps to the letter below it. Because of this property, we will use a character-level RNN for this cipher, although word-level RNNs may be more common in practice.
Why use an RNN?
A Caesar Cipher can be solved as a multiclass classification problem using a fully-connected feedforward neural network since each letter X maps to its cipher value Y. However, an…