EricGuo5513 / momask-codes

Official implementation of "MoMask: Generative Masked Modeling of 3D Human Motions (CVPR2024)"
https://ericguo5513.github.io/momask/
MIT License
856 stars 73 forks source link

loss function confusion in vq_trainer.py #30

Closed Keneyr closed 3 weeks ago

Keneyr commented 8 months ago

Hi Eric, in your paper, the loss item for vqvae is "motion reconstruction loss combined with a latent embedding loss at each quantization layer"

However, the code for loss function have three items: loss_rec, loss_explicit, loss_commit:

def forward(self, batch_data):
        motions = batch_data.detach().to(self.device).float()
        pred_motion, loss_commit, perplexity = self.vq_model(motions)

        self.motions = motions
        self.pred_motion = pred_motion

        loss_rec = self.l1_criterion(pred_motion, motions)
        pred_local_pos = pred_motion[..., 4 : (self.opt.joints_num - 1) * 3 + 4]
        local_pos = motions[..., 4 : (self.opt.joints_num - 1) * 3 + 4]
        loss_explicit = self.l1_criterion(pred_local_pos, local_pos)

        loss = loss_rec + self.opt.loss_vel * loss_explicit + self.opt.commit * loss_commit

        # return loss, loss_rec, loss_vel, loss_commit, perplexity
        # return loss, loss_rec, loss_percept, loss_commit, perplexity
        return loss, loss_rec, loss_explicit, loss_commit, perplexity

I guess the loss_rec and loss_commit items are presented in the paper, but what is the meaning of loss_explicit? Sorry if I have missed anything... Thank you!

EricGuo5513 commented 7 months ago

Hi, sorry for the late reply. Here we just want to emphasize a bit more on the position reconstruction.