Created
August 10, 2023 13:19
-
-
Save pythonlessons/9ce3b86715db76e24658c1faac324577 to your computer and use it in GitHub Desktop.
transformers_introduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pos_encoding /= tf.norm(pos_encoding, axis=1, keepdims=True) | |
| p = pos_encoding[1000] | |
| dots = tf.einsum('pd,d->p', pos_encoding, p).numpy() | |
| plt.subplot(2, 1, 1) | |
| plt.plot(dots) | |
| plt.ylim([0, 1]) | |
| plt.plot([950, 950, float('nan'), 1050, 1050], [0, 1, float('nan'), 0, 1], color='k', label='Zoom') | |
| plt.legend() | |
| plt.subplot(2, 1, 2) | |
| plt.plot(range(len(dots)), dots) | |
| plt.xlim([950, 1050]) | |
| plt.ylim([0, 1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment