yoshall / AirFormer

PyTorch implementation of AirFormer, AAAI-23
99 stars 22 forks source link

generate assignment.npy #5

Open spiritcommonsix opened 10 months ago

spiritcommonsix commented 10 months ago

I don't understand "Dartboard Projection & MSA" in the paper and the assignment.npy is given in the code. Could you share the method of generating assignment.npy? Thanks for your work!

G-H-Li commented 8 months ago

@spiritcommonsix Have you figured out how assignment.npy is generated, please?

After reading the article carefully, I realized that there is a dimensional inconsistency between the way the assignment matrix is calculated according to the article, and assignment.npy.

It is written below in the article:

For a certain station i, we unify the formulation of the dartboard projection by introducing a projection matrix Ai ∈ RM×N which denotes how nearby stations are mapped to M regions bound by the line fragments and circles, where each entry ajk ≥ 0 denotes the likelihood that the k-th station belongs to the region j. Ai has each row summing to one and each non-zero entry in the same row is evenly distributed (like average pooling).

According to my understanding, assignment.npy should be a stacked matrix of N sites Ai. assignment.npy has dimension (N, N, M). The text says that the dimension of Ai is (M, N), so the Ai matrix should have undergone a transpose operation and then been stacked.

Also, according to what is written in the article:

Ai has each row summing to one and each non-zero entry in the same row is evenly distributed (like average pooling).

Then I wrote a code to kern the values in assignment.npy as follows:

if __name__ == '__main__':
    a = np.load(os.path.join(Config().dataset_dir, 'assignment.npy'))  # read assignment.npy
    a = torch.from_numpy(a[:, 0])
    row = a.transpose(1, 0)
    row_sums = row.sum(axis=1)
    print(row_sums)

But the result I get is not for every row M, where the values sum to 1. image

I'm not sure if I'm understanding this correctly. I hope the author can correct me if there is a problem. At the same time, I also hope very much that the authors can publicize the code for generating mask.npy and assignemnt.npy, so that it is convenient for people to migrate and reproduce the paper, and further improve the academic impact of this article.

Looking forward to the author's reply.