XiaolongTang23 / HPNet

[CVPR 2024] HPNet: Dynamic Trajectory Forecasting with Historical Prediction Attention
Apache License 2.0
96 stars 11 forks source link

Errror when calling dense_to_sparse function #5

Closed youngzhou1999 closed 2 months ago

youngzhou1999 commented 2 months ago

Hi, xiaolong. Thanks for the great public code. I tried to run your code and met the following error.

File "/mnt/cache/zhouyang4/.local/lib/python3.8/site-packages/torch_geometric/utils/sparse.py", line 37, in dense_to_sparse
    assert adj.size(-1) == adj.size(-2)
AssertionError

It seems that the line t2m_valid_mask = t2m_valid_mask_t.unsqueeze(2) & t2m_valid_mask_m.unsqueeze(1) #[(N1,...,Nb),H,H*K] doesn't follow the shape required by dense_to_sparse according to https://pytorch-geometric.readthedocs.io/en/latest/modules/utils.html#torch_geometric.utils.dense_to_sparse.

XiaolongTang23 commented 2 months ago

Hi, thank you for trying out the code and reporting this issue.

I apologize for the inconvenience. Based on the error you encountered, I suspect this might be due to the version of PyTorch Geometric you are using. In versions prior to 2.3.0, the dense_to_sparse function requires the tensor's last two dimensions to be of equal size. However, this requirement has been relaxed in version 2.3.0 and later. Could you please check your PyTorch Geometric version and consider updating it if it's older than 2.3.0?

This should resolve the issue. Please let me know if the problem persists after updating.

youngzhou1999 commented 2 months ago

Cool. I upgrade pyg to 2.3.1 and now it seems fine for training. Thanks for your helpful solution.