Abdullah-Nazhat commited on
Commit
1c532b3
·
verified ·
1 Parent(s): 1c79919

Update tensormapper.py

Browse files
Files changed (1) hide show
  1. tensormapper.py +5 -21
tensormapper.py CHANGED
@@ -1,8 +1,6 @@
1
  import torch
2
  from torch import nn, Tensor
3
 
4
-
5
-
6
  class VecDyT(nn.Module):
7
  def __init__(self, input_shape):
8
 
@@ -13,8 +11,7 @@ class VecDyT(nn.Module):
13
  def forward(self, x):
14
  x = torch.tanh(self.alpha * x)
15
  return x
16
-
17
-
18
  class GatingUnit(nn.Module):
19
  def __init__(self,dim):
20
 
@@ -24,8 +21,7 @@ class GatingUnit(nn.Module):
24
  self.proj_2 = nn.Linear(dim,dim,bias=False)
25
 
26
  self.gelu = nn.GELU()
27
-
28
-
29
  def forward(self, x):
30
 
31
  u, v = x, x
@@ -40,15 +36,12 @@ class TTT(nn.Module):
40
  def __init__(self, dim: int):
41
 
42
  super(TTT, self).__init__()
43
-
44
-
45
  self.mapping = nn.Linear(dim,dim,bias=False)
46
  self.State = nn.Linear(dim,dim,bias=False)
47
  self.Probe = nn.Linear(dim,dim,bias=False)
48
-
49
-
50
  def forward(self, in_seq: Tensor) -> Tensor:
51
-
52
 
53
  outs = []
54
 
@@ -70,8 +63,6 @@ class TTT(nn.Module):
70
 
71
  return out
72
 
73
-
74
-
75
  class TensorMapperBlock(nn.Module):
76
  def __init__(self, dim):
77
 
@@ -84,9 +75,7 @@ class TensorMapperBlock(nn.Module):
84
 
85
 
86
  def forward(self, x):
87
-
88
-
89
-
90
  residual = x
91
 
92
  x = self.norm_1(x)
@@ -105,7 +94,6 @@ class TensorMapperBlock(nn.Module):
105
 
106
  return x
107
 
108
-
109
  class TensorMapper(nn.Module):
110
  def __init__(self, d_model, num_layers):
111
  super().__init__()
@@ -117,7 +105,3 @@ class TensorMapper(nn.Module):
117
  def forward(self, x):
118
 
119
  return self.model(x)
120
-
121
-
122
-
123
-
 
1
  import torch
2
  from torch import nn, Tensor
3
 
 
 
4
  class VecDyT(nn.Module):
5
  def __init__(self, input_shape):
6
 
 
11
  def forward(self, x):
12
  x = torch.tanh(self.alpha * x)
13
  return x
14
+
 
15
  class GatingUnit(nn.Module):
16
  def __init__(self,dim):
17
 
 
21
  self.proj_2 = nn.Linear(dim,dim,bias=False)
22
 
23
  self.gelu = nn.GELU()
24
+
 
25
  def forward(self, x):
26
 
27
  u, v = x, x
 
36
  def __init__(self, dim: int):
37
 
38
  super(TTT, self).__init__()
39
+
 
40
  self.mapping = nn.Linear(dim,dim,bias=False)
41
  self.State = nn.Linear(dim,dim,bias=False)
42
  self.Probe = nn.Linear(dim,dim,bias=False)
43
+
 
44
  def forward(self, in_seq: Tensor) -> Tensor:
 
45
 
46
  outs = []
47
 
 
63
 
64
  return out
65
 
 
 
66
  class TensorMapperBlock(nn.Module):
67
  def __init__(self, dim):
68
 
 
75
 
76
 
77
  def forward(self, x):
78
+
 
 
79
  residual = x
80
 
81
  x = self.norm_1(x)
 
94
 
95
  return x
96
 
 
97
  class TensorMapper(nn.Module):
98
  def __init__(self, d_model, num_layers):
99
  super().__init__()
 
105
  def forward(self, x):
106
 
107
  return self.model(x)