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

Method forward

plot-adapter/main_imagenet.py:63–74  ·  view source on GitHub ↗
(self, prompts, tokenized_prompts)

Source from the content-addressed store, hash-verified

61 self.dtype = clip_model.dtype
62
63 def forward(self, prompts, tokenized_prompts):
64
65 x = prompts + self.positional_embedding.type(self.dtype)
66
67 x = x.permute(1, 0, 2) # NLD -> LND
68 x = self.transformer(x)
69 x = x.permute(1, 0, 2) # LND -> NLD
70 x = self.ln_final(x).type(self.dtype)
71
72 x = x[torch.arange(x.shape[0]), tokenized_prompts.argmax(dim=-1)] @ self.text_projection
73
74 return x
75
76
77class PromptLearner(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected