facebookresearch / mae

PyTorch implementation of MAE https//arxiv.org/abs/2111.06377
Other
6.93k stars 1.17k forks source link

About the gan-loss #181

Open cannonli7 opened 8 months ago

cannonli7 commented 8 months ago

Thanks for your work. Im a little curious about the code of the gan loss in MAE? But i cannot find the code in this repository. could you help me with that

tangky22 commented 5 months ago

Thanks for your work. Im a little curious about the code of the gan loss in MAE? But i cannot find the code in this repository. could you help me with that

Hello, I also curious about the gan loss in MAE. I found the process is the same when loading two models in demo.py and I also couldn't find definiton of gan loss in the code. Have you solve the problem?

kevin-Abbring commented 2 months ago

Thanks for your work. Im a little curious about the code of the gan loss in MAE? But i cannot find the code in this repository. could you help me with that

def forward_loss(self, imgs, pred, mask):
    """
    imgs: [N, 3, H, W]
    pred: [N, L, p*p*3]
    mask: [N, L], 0 is keep, 1 is remove, 
    """
    target = self.patchify(imgs)
    if self.norm_pix_loss:
        mean = target.mean(dim=-1, keepdim=True)
        var = target.var(dim=-1, keepdim=True)
        target = (target - mean) / (var + 1.e-6)**.5

    loss = (pred - target) ** 2
    loss = loss.mean(dim=-1)  # [N, L], mean loss per patch

    loss = (loss * mask).sum() / mask.sum()  # mean loss on removed patches
    return loss

    如果不是,就是?我也没有找到明文的gan_loss代码,只能暂且这么认为。