Skip to content

flow_loss implementation in HuggingFace may have an issue related to velocity computation. #4

Open
@liq22

Description

@liq22

Hi, thanks for your work.
Should the variable target be equal to target - noise in your flow loss?

This version seems to predict the target sample directly, rather than the velocity.

 def forward(self, target, z, mask=None, mask_y=None):

    noise = torch.randn_like(target)

    t = torch.rand(target.shape[0], device=target.device)

    noised_target = t[:, None] * target + (1 - t[:, None]) * noise

    predict_v = self.net(noised_target, t * 1000, z)

    weights = 1.0 / \
        torch.arange(1, self.in_channels + 1, dtype=torch.float32, device=target.device)
    if mask_y is not None:
        loss = (mask_y * weights * (predict_v - target) ** 2).sum(dim=-1)
    else:
        loss = (weights * (predict_v - target) ** 2).sum(dim=-1)

    if mask is not None:
        loss = (loss * mask).sum() / mask.sum()
    return loss.mean()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions