MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / Transformer

Class Transformer

sat/sgm/modules/encoders/traj_encoder.py:79–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 return self.to_out(out)
78
79class Transformer(nn.Module):
80 def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout = 0.):
81 super().__init__()
82 self.layers = nn.ModuleList([])
83 for _ in range(depth):
84 self.layers.append(nn.ModuleList([
85 Attention(dim, heads = heads, dim_head = dim_head, dropout = dropout),
86 FeedForward(dim, mlp_dim, dropout = dropout)
87 ]))
88 def forward(self, x):
89 for attn, ff in self.layers:
90 x = attn(x) + x
91 x = ff(x) + x
92 return x
93
94class ViT(nn.Module):
95 def __init__(self, *, seq_len, patch_size, num_classes, dim, depth, heads, mlp_dim, channels = 3, dim_head = 64, dropout = 0., emb_dropout = 0.):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected