MCPcopy Create free account
hub / github.com/CHENGY12/PLOT / forward

Method forward

plot-coop/trainers/plot.py:46–57  ·  view source on GitHub ↗
(self, prompts, tokenized_prompts)

Source from the content-addressed store, hash-verified

44 self.dtype = clip_model.dtype
45
46 def forward(self, prompts, tokenized_prompts):
47
48 x = prompts + self.positional_embedding.type(self.dtype)
49
50 x = x.permute(1, 0, 2) # NLD -> LND
51 x = self.transformer(x)
52 x = x.permute(1, 0, 2) # LND -> NLD
53 x = self.ln_final(x).type(self.dtype)
54
55 x = x[torch.arange(x.shape[0]), tokenized_prompts.argmax(dim=-1)] @ self.text_projection
56
57 return x
58
59
60class PromptLearner(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected