Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def positional_encoding(inputs,

# First part of the PE function: sin and cos argument
position_enc = np.array([
[pos / np.power(10000, (i-i%2)/E) for i in range(E)]
[pos / np.power(10000, 1.0*(i-i%2)/E) for i in range(E)]
for pos in range(maxlen)])

# Second part, apply the cosine to even columns and sin to odds.
Expand All @@ -308,4 +308,4 @@ def noam_scheme(init_lr, global_step, warmup_steps=4000.):
until it reaches init_lr.
'''
step = tf.cast(global_step + 1, dtype=tf.float32)
return init_lr * warmup_steps ** 0.5 * tf.minimum(step * warmup_steps ** -1.5, step ** -0.5)
return init_lr * warmup_steps ** 0.5 * tf.minimum(step * warmup_steps ** -1.5, step ** -0.5)