vincent-leguen / DILATE

Code for our NeurIPS 2019 paper "Shape and Time Distortion Loss for Training Deep Time Series Forecasting Models"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multidimensional outputs

talsperre opened this issue · comments

Thanks a lot for the code release.

I had a doubt regarding your code. How can I extend the loss function for cases with multi-dimensional outputs like vehicle trajectory forecasting (2D)? Currently, the code does not support this I assume.

Any suggestions on the changes I need to make to the code / other references would be really helpful.

Thank you @talsperre for your feedback, the code is currently indeed ont supporting 1D series. It is possible to entend to multivariate series by computing the pairwise cost matrix for DTW with vector L2 distance.

Thanks a lot for the code release. I want to extend the loss function for cases with multi-dimensional output(such i want to predict PM25 and PM10), Am I writing it correctly? Any suggestions on the changes I need to make to the code / other references would be really helpful.


def dilate_loss_multi(outputs, targets, alpha, gamma, device):

    batch_size, N_output, out_size = outputs.shape
    individul_loss = torch.zeros(out_size).float().to(device)
    individul_loss_shape = torch.zeros(out_size).float().to(device)
    individul_loss_temporal = torch.zeros(out_size).float().to(device)
    for i in range(out_size):
        loss, loss_shape, loss_temporal = dilate_loss(
            outputs[:, :, i:i + 1], targets[:, :, i:i + 1], alpha, gamma, device)
        individul_loss[i] = loss
        individul_loss_shape[i] = loss_shape
        individul_loss_temporal[i] = loss_temporal

    return (torch.mean(individul_loss),
            torch.mean(individul_loss_shape),
            torch.mean(individul_loss_temporal)
    )

Thanks a lot for the code release. I want to extend the loss function for cases with multi-dimensional output(such i want to predict PM25 and PM10), Am I writing it correctly? Any suggestions on the changes I need to make to the code / other references would be really helpful.


def dilate_loss_multi(outputs, targets, alpha, gamma, device):

    batch_size, N_output, out_size = outputs.shape
    individul_loss = torch.zeros(out_size).float().to(device)
    individul_loss_shape = torch.zeros(out_size).float().to(device)
    individul_loss_temporal = torch.zeros(out_size).float().to(device)
    for i in range(out_size):
        loss, loss_shape, loss_temporal = dilate_loss(
            outputs[:, :, i:i + 1], targets[:, :, i:i + 1], alpha, gamma, device)
        individul_loss[i] = loss
        individul_loss_shape[i] = loss_shape
        individul_loss_temporal[i] = loss_temporal

    return (torch.mean(individul_loss),
            torch.mean(individul_loss_shape),
            torch.mean(individul_loss_temporal)
    )

same question. Can this code be worked?