MCPcopy Create free account
hub / github.com/caoql98/DCPL / forward

Method forward

trainers/vpt.py:53–64  ·  view source on GitHub ↗
(self, prompts, tokenized_prompts)

Source from the content-addressed store, hash-verified

51 self.dtype = clip_model.dtype
52
53 def forward(self, prompts, tokenized_prompts):
54 x = prompts + self.positional_embedding.type(self.dtype)
55 x = x.permute(1, 0, 2) # NLD -> LND
56 x = self.transformer(x)
57 x = x.permute(1, 0, 2) # LND -> NLD
58 x = self.ln_final(x).type(self.dtype)
59
60 # x.shape = [batch_size, n_ctx, transformer.width]
61 # take features from the eot embedding (eot_token is the highest number in each sequence)
62 x = x[torch.arange(x.shape[0]), tokenized_prompts.argmax(dim=-1)] @ self.text_projection
63
64 return x
65
66
67class FixedEmbeddings():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected