Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidimensional outputs #3

Open
talsperre opened this issue Dec 8, 2019 · 3 comments
Open

Multidimensional outputs #3

talsperre opened this issue Dec 8, 2019 · 3 comments

Comments

@talsperre
Copy link

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.

@vincent-leguen
Copy link
Owner

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.

@Empythy
Copy link

Empythy commented Nov 12, 2020

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)
    )

@Jeffrey-JDong
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants