Chiaraplizz / ST-TR

Spatial Temporal Transformer Network for Skeleton-Based Activity Recognition
MIT License
299 stars 58 forks source link

Code problem #8

Closed wangzeyu135798 closed 3 years ago

wangzeyu135798 commented 3 years ago

Hi: I found there is a problem exist in you code. In st_gcn.py line 110, a tensor named self.A , stands for three adjacency matrix of Kinetics. In unitagcn.py, line 47 and 48 self.PA = torch.nn.Parameter(A) torch.nn.init.constant(self.PA, 1e-6) The problem is when A is tensor type, after the initialization, the formal parameter A and the actual parameter self.A will be changed to the initialized result 1e-6 . That means the next agcn(gcn) adjacency matrix will all be a tensor of (3, 18, 18) shape and 1e-6 value, so this caused adjacency matrix information is useless in gcn state. I found when line47 variable A is array type, it will be consistent after torch.nn.paramter.init operation.

wangzeyu135798 commented 3 years ago

In st_gcn.py line 196 and line 222, there are two same variable self.backbone which is assigned two times, is it right ?

Chiaraplizz commented 3 years ago

In st_gcn.py line 196 and line 222, there are two same variable self.backbone which is assigned two times, is it right ?

Oh, I think you're right! The first assignment was useless! Thanks ;)

Chiaraplizz commented 3 years ago

Hi: I found there is a problem exist in you code. In st_gcn.py line 110, a tensor named self.A , stands for three adjacency matrix of Kinetics. In unitagcn.py, line 47 and 48 self.PA = torch.nn.Parameter(A) torch.nn.init.constant(self.PA, 1e-6) The problem is when A is tensor type, after the initialization, the formal parameter A and the actual parameter self.A will be changed to the initialized result 1e-6 . That means the next agcn(gcn) adjacency matrix will all be a tensor of (3, 18, 18) shape and 1e-6 value, so this caused adjacency matrix information is useless in gcn state. I found when line47 variable A is array type, it will be consistent after torch.nn.paramter.init operation.

Thanks! I noticed that if I initialize as self.PA = nn.Parameter(torch.from_numpy(A.astype(np.float32))) the problem does not occur.

Chiara