Abdullah-Nazhat commited on
Commit
fb758c5
·
verified ·
1 Parent(s): cf3a184

Update normalizer.py

Browse files
Files changed (1) hide show
  1. normalizer.py +7 -7
normalizer.py CHANGED
@@ -2,11 +2,11 @@ import torch
2
  from torch import nn
3
 
4
  class GatingUnit(nn.Module):
5
- def __init__(self, dim):
6
  super().__init__()
7
- self.proj_1 = nn.Linear(dim, dim)
8
- self.proj_2 = nn.Linear(dim, dim)
9
- self.proj_3 = nn.Linear(dim, dim)
10
  self.silu = nn.SiLU()
11
 
12
  def forward(self, x):
@@ -23,12 +23,12 @@ class GatingUnit(nn.Module):
23
  return out
24
 
25
  class NormalizerBlock(nn.Module):
26
- def __init__(self, d_model, num_tokens):
27
  super().__init__()
28
 
29
  self.norm_global = nn.LayerNorm(d_model * num_tokens, elementwise_affine=False)
30
  self.norm_local = nn.LayerNorm(d_model, elementwise_affine=False)
31
- self.gating = GatingUnit(d_model)
32
 
33
  def forward(self, x):
34
 
@@ -53,7 +53,7 @@ class NormalizerBlock(nn.Module):
53
  return out
54
 
55
  class Normalizer(nn.Module):
56
- def __init__(self, d_model, num_tokens, num_layers):
57
  super().__init__()
58
 
59
  self.model = nn.Sequential(
 
2
  from torch import nn
3
 
4
  class GatingUnit(nn.Module):
5
+ def __init__(self, dim, hidden_dim):
6
  super().__init__()
7
+ self.proj_1 = nn.Linear(dim, hidden_dim)
8
+ self.proj_2 = nn.Linear(dim, hidden_dim)
9
+ self.proj_3 = nn.Linear(hidden_dim, dim)
10
  self.silu = nn.SiLU()
11
 
12
  def forward(self, x):
 
23
  return out
24
 
25
  class NormalizerBlock(nn.Module):
26
+ def __init__(self, d_model, d_ffn, num_tokens):
27
  super().__init__()
28
 
29
  self.norm_global = nn.LayerNorm(d_model * num_tokens, elementwise_affine=False)
30
  self.norm_local = nn.LayerNorm(d_model, elementwise_affine=False)
31
+ self.gating = GatingUnit(d_model, d_ffn)
32
 
33
  def forward(self, x):
34
 
 
53
  return out
54
 
55
  class Normalizer(nn.Module):
56
+ def __init__(self, d_model, d_ffn, num_tokens, num_layers):
57
  super().__init__()
58
 
59
  self.model = nn.Sequential(