abduallahmohamed / Social-STGCNN

Code for "Social-STGCNN: A Social Spatio-Temporal Graph Convolutional Neural Network for Human Trajectory Prediction" CVPR 2020
MIT License
483 stars 141 forks source link

I am very curious about the element in your proposed adjacency matrix #66

Closed WangHonghui123 closed 1 year ago

WangHonghui123 commented 1 year ago

When I see your code, why do you use the relative position to calculate the norm between two nodes in a graph under a frame, shown as follows:

def seq_tograph(seq,seq_rel,norm_lapmatr = True): seq = seq_.squeeze() seq_rel = seq_rel.squeeze() seqlen = seq.shape[2] maxnodes = seq.shape[0]

V = np.zeros((seq_len,max_nodes,2))
A = np.zeros((seq_len,max_nodes,max_nodes))
for s in range(seq_len):
    step_ = seq_[:,:,s] 
    step_rel = seq_rel[:,:,s] 
    for h in range(len(step_)): 
        V[s,h,:] = step_rel[h]
        A[s,h,h] = 1 
        for k in range(h+1,len(step_)):
            **l2_norm = anorm(step_rel[h],step_rel[k])** 
            A[s,h,k] = l2_norm
            A[s,k,h] = l2_norm
    if norm_lap_matr:  
        G = nx.from_numpy_matrix(A[s,:,:])
        A[s,:,:] = nx.normalized_laplacian_matrix(G).toarray()

return torch.from_numpy(V).type(torch.float),\
       torch.from_numpy(A).type(torch.float)