22.02.2024 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Let’s put both sine and cosine values together and look at the first four positions:

np.round(encoding[0:4], 4) # first four positions

Output

tensor([[ 0.0000, 1.0000, 0.0000, 1.0000, 0.0000, 1.0000,

0.0000, 1.0000],

[ 0.8415, 0.5403, 0.0998, 0.9950, 0.0100, 1.0000,

0.0010, 1.0000],

[ 0.9093, -0.4161, 0.1987, 0.9801, 0.0200, 0.9998,

0.0020, 1.0000],

[ 0.1411, -0.9900, 0.2955, 0.9553, 0.0300, 0.9996,

0.0030, 1.0000]])

Each line above represents the encoding values for each of its eight dimensions.

The first position will always have alternated zeros and ones (the sine and cosine

of zero, respectively).

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

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

Saved successfully!

Ooh no, something went wrong!