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

The loss of STSGCN is irregularly large #311

Merged
merged 2 commits into from
Sep 7, 2022

Conversation

SonghuaHu-UMD
Copy link
Contributor

I am currently testing the STSGCN and found the loss is irregularly large (>1e10).
I read the code and found the output is accumulated after the graph convolution:


I checked the paper and code and thought they use the distance inverse as the adjacent matrix, rather than the Gauss kernel (https://github.com/Davidham3/STSGCN/blob/master/utils.py#L105).

    # Fills cells in the matrix with distances.
    with open(distance_df_filename, 'r') as f:
        f.readline()
        reader = csv.reader(f)
        for row in reader:
            if len(row) != 3:
                continue
            i, j, distance = int(row[0]), int(row[1]), float(row[2])
            if type_ == 'connectivity':
                A[i, j] = 1
                A[j, i] = 1
            elif type == 'distance':
                A[i, j] = 1 / distance
                A[j, i] = 1 / distance
            else:
                raise ValueError("type_ error, must be "
                                 "connectivity or distance!")
    return A

I added a new function in traffic_state_dataset to calculate the distance inverse for STSGCN and the loss now looks reasonable
(PEMSD7(M), 12 prediction steps):

MAE MAPE MSE RMSE masked_MAE masked_MAPE masked_MSE masked_RMSE R2 EVAR
1.461792 0.033766 6.305071 2.51099 1.461792 0.033766 6.305071 2.51099 0.966612 0.967362
1.886784 0.044624 12.02078 3.4671 1.886784 0.044624 12.02078 3.4671 0.936329 0.937318
2.208205 0.05365 17.84879 4.224782 2.208205 0.05365 17.84879 4.224782 0.90546 0.907067
2.445271 0.060798 23.0774 4.803894 2.445271 0.060798 23.0774 4.803894 0.877856 0.879756
2.636102 0.067311 27.92206 5.284132 2.636102 0.067311 27.92206 5.284132 0.852311 0.854849
2.793431 0.072273 32.20569 5.675005 2.793431 0.072273 32.20569 5.675005 0.829672 0.8325
2.914345 0.076151 35.48109 5.956601 2.914345 0.076151 35.48109 5.956601 0.812326 0.815592
3.017157 0.079508 38.48553 6.203671 3.017157 0.079508 38.48553 6.203671 0.796511 0.799579
3.103143 0.082126 40.83116 6.389926 3.103143 0.082126 40.83116 6.389926 0.784075 0.786962
3.165864 0.084001 42.70291 6.534747 3.165864 0.084001 42.70291 6.534747 0.774234 0.776773
3.236152 0.086049 44.63507 6.680949 3.236152 0.086049 44.63507 6.680949 0.763969 0.766483
3.298688 0.087792 46.06493 6.787116 3.298688 0.087792 46.06493 6.787116 0.756369 0.75932

@aptx1231
Copy link
Member

aptx1231 commented Sep 6, 2022

Good job! Thank you!

@aptx1231
Copy link
Member

aptx1231 commented Sep 6, 2022

You can merge this PR.

@SonghuaHu-UMD
Copy link
Contributor Author

You can merge this PR.

Thanks for approving! I don't have the write access so I could not merge this PR.

@aptx1231 aptx1231 merged commit db7d51c into LibCity:master Sep 7, 2022
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

Successfully merging this pull request may close these issues.

2 participants