Skip to content

Commit

Permalink
Update Embed.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhaixu2016 authored Nov 25, 2022
1 parent 8798848 commit 66181a1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions layers/Embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@
from torch.nn.utils import weight_norm
import math

def compared_version(ver1, ver2):
"""
:param ver1
:param ver2
:return: ver1< = >ver2返回False/True
"""
list1 = str(ver1).split(".")
list2 = str(ver2).split(".")

for i in range(len(list1)) if len(list1) < len(list2) else range(len(list2)):
if int(list1[i]) == int(list2[i]):
pass
elif int(list1[i]) < int(list2[i]):
return -1
else:
return 1

if len(list1) == len(list2):
return True
elif len(list1) < len(list2):
return False
else:
return True

class PositionalEmbedding(nn.Module):
def __init__(self, d_model, max_len=5000):
Expand Down

0 comments on commit 66181a1

Please sign in to comment.