4 ms·
Am I reading the example correctly? The prompt is the same size as the generated code, and likely more difficult to understand? Why would you use that? Why woul
by jpollock 2y ago
Am I reading the example correctly? The prompt is the same size as the generated code, and likely more difficult to understand? Why would you use that? Why would you use anything that includes a "TODO"?
-- ignoring what I would consider "weird" in the code, I assume that's just style.
The prompt is:
This function performs a forward pass for a model, incorporating conditioning and time step information.
It randomly selects time steps, applies learned conditioning if applicable, and processes the inputs according to the model's conditioning
requirements.
Finally, it computes and returns the loss for the given inputs and conditioning.
The ground truth (am I correct, this is the expected answer?) is:
def forward(self, x, c, *args, **kwargs):
t = torch.randint(0, self.num_timesteps, (x.shape[0],), device=self.device).long()
logging.info(f'Random timestep t generated with shape: {t.shape}')
if self.model.conditioning_key is not None:
assert c is not None
if self.cond_stage_trainable:
c = self.get_learned_conditioning(c)
if self.shorten_cond_schedule: # TODO: drop this option
tc = self.cond_ids[t].to(self.device)
c = self.q_sample(x_start=c, t=tc, noise=torch.randn_like(c.float()))
return self.p_losses(x, c, t, *args, **kwargs)