To answer your question: the sentence does not go through all 1024 GRU units. A better way to put it would be something like every character is converted to a representation with 1024 elements.
The details (in the linked example):
Every sentence is to be understood as a sequence of characters.
The key is that an RNN actually operates on single characters.
If you are familiar with programming, you can think of it as a for
loop.
Concretely, an RNN generally operates as follows:
- initialise the state of a pre-specified size (1024)
- take the next element (char) in the sequence (sentence)
- map the input element (char) to a representation with the same size as its state (1024)
- apply a linear transformation on the state (from the previous iteration)
- compute a (non-linear) transformation on the results from 2 and 3 and make this the new state.
- jump to step 1 if more elements (chars) are available in the sequence (sentence).
Since, normally, each of the entries in the RNN state vector are independent from each other, they are often considered as individual entities. Therefore, the entries in an RNN state vector are also commonly referred to as units or cells. So, if your RNN has 1024 units, it actually just has a state vector $\in \mathbb{R}^{1024}$.
NOTE: for the sake of simplicity I ignored the fact that every character is normally first transformed/embedded in some vector space (done by tf.keras.layers.Embedding
in the example) and these embeddings actually make up the elements of the sequence (instead of the chars).