22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 9.44 - Representing degrees on a circle

Moreover, the circles above show the sine and cosine values corresponding to the

coordinates of the tip of each red arrow (assuming a circle with a radius of one).

The sine and cosine values, that is, the coordinates of the red

arrow, are the actual positional encoding of a given position.

We can simply read the sine and cosine values, from top to bottom, to build the

encodings for each position.

Figure 9.45 - Representing degrees using sine and cosine

There were three vectors, thus generating six coordinates or dimensions (three

sines and three cosines).

Next, let’s use these encodings to calculate the distances, which should be

consistent now!

768 | Chapter 9 — Part II: Sequence-to-Sequence

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!