MCPcopy Create free account
hub / github.com/OpenSparseLLMs/Linear-MoE / HadamardFeatureMap

Class HadamardFeatureMap

linear_moe/model/common_modules/feature_map.py:119–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119class HadamardFeatureMap(nn.Module):
120 def __init__(
121 self,
122 head_dim: int
123 ) -> HadamardFeatureMap:
124 super().__init__()
125 # Trainable map
126 self.layer1 = nn.Linear(head_dim, head_dim)
127 self.layer2 = nn.Linear(head_dim, head_dim)
128
129 def forward(self, x: torch.Tensor):
130 return self.layer1(x) * self.layer2(x)
131
132
133class LearnableOuterProductFeatureMap(nn.Module):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected