Skip to content

Instantly share code, notes, and snippets.

@pythonlessons
Created August 10, 2023 13:19
Show Gist options
  • Select an option

  • Save pythonlessons/e845a977db9b37c5aa10c8ca14cdff97 to your computer and use it in GitHub Desktop.

Select an option

Save pythonlessons/e845a977db9b37c5aa10c8ca14cdff97 to your computer and use it in GitHub Desktop.
transformers_introduction
import matplotlib.pyplot as plt
pos_encoding = positional_encoding(length=2048, depth=512)
# Check the shape.
print(pos_encoding.shape)
# Plot the dimensions.
plt.pcolormesh(pos_encoding.numpy().T, cmap='RdBu')
plt.ylabel('Depth')
plt.xlabel('Position')
plt.colorbar()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment