Commit cf647057 by Leo

upload code

parent c42b8782
This source diff could not be displayed because it is too large. You can view the blob instead.
import numpy as np
import numpy as np
def get_positional_encoding(max_len, d_model):
positional_encoding = np.zeros((max_len, d_model))
for pos in range(max_len):
for i in range(0, d_model, 2):
positional_encoding[pos, i] = np.sin(pos / (10000 ** ((2 * i) / d_model)))
if i + 1 < d_model:
positional_encoding[pos, i + 1] = np.cos(pos / (10000 ** ((2 * i) / d_model)))
return positional_encoding
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
-- "a/2-\345\272\224\347\224\250/2.17-\350\257\255\351\237\263\344\272\244\344\272\222/.gitkeep"
++ /dev/null
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment