MCPcopy Index your code
hub / github.com/MotrixLab/MotionDiffuse / StylizationBlock

Class StylizationBlock

text2motion/models/transformer.py:60–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class StylizationBlock(nn.Module):
61
62 def __init__(self, latent_dim, time_embed_dim, dropout):
63 super().__init__()
64 self.emb_layers = nn.Sequential(
65 nn.SiLU(),
66 nn.Linear(time_embed_dim, 2 * latent_dim),
67 )
68 self.norm = nn.LayerNorm(latent_dim)
69 self.out_layers = nn.Sequential(
70 nn.SiLU(),
71 nn.Dropout(p=dropout),
72 zero_module(nn.Linear(latent_dim, latent_dim)),
73 )
74
75 def forward(self, h, emb):
76 """
77 h: B, T, D
78 emb: B, D
79 """
80 # B, 1, 2D
81 emb_out = self.emb_layers(emb).unsqueeze(1)
82 # scale: B, 1, D / shift: B, 1, D
83 scale, shift = torch.chunk(emb_out, 2, dim=2)
84 h = self.norm(h) * (1 + scale) + shift
85 h = self.out_layers(h)
86 return h
87
88
89class LinearTemporalSelfAttention(nn.Module):

Callers 5

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected