MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / Mlp

Class Mlp

examples/diffusion/python_stable_diffusion_3/other_impls.py:45–60  ·  view source on GitHub ↗

MLP as used in Vision Transformer, MLP-Mixer and related networks

Source from the content-addressed store, hash-verified

43
44
45class Mlp(nn.Module):
46 """ MLP as used in Vision Transformer, MLP-Mixer and related networks"""
47 def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, bias=True, dtype=None, device=None):
48 super().__init__()
49 out_features = out_features or in_features
50 hidden_features = hidden_features or in_features
51
52 self.fc1 = nn.Linear(in_features, hidden_features, bias=bias, dtype=dtype, device=device)
53 self.act = act_layer
54 self.fc2 = nn.Linear(hidden_features, out_features, bias=bias, dtype=dtype, device=device)
55
56 def forward(self, x):
57 x = self.fc1(x)
58 x = self.act(x)
59 x = self.fc2(x)
60 return x
61
62
63#################################################################################################

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected