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