MCPcopy Create free account
hub / github.com/Gabesarch/ICAL / tensor2summ

Function tensor2summ

TEACh/utils/basic.py:23–37  ·  view source on GitHub ↗
(tensor, permute_dim=False)

Source from the content-addressed store, hash-verified

21 print(name, tensor, tensor.shape)
22
23def tensor2summ(tensor, permute_dim=False):
24 # if permute_dim = True:
25 # for 2d tensor, assume input is torch format B x S x C x H x W, we want B x S x H x W x C
26 # for 3d tensor, assume input is torch format B x S x C x H x W x D, we want B x S x H x W x C x D
27 # and finally unbind the sequeence dimension and return a list of [B x H x W x C].
28 assert(tensor.ndim == 5 or tensor.ndim == 6)
29 assert(tensor.size()[1] == 2) #sequense length should be 2
30 if permute_dim:
31 if tensor.ndim == 6: #3d tensor
32 tensor = tensor.permute(0, 1, 3, 4, 5, 2)
33 elif tensor.ndim == 5: #2d tensor
34 tensor = tensor.permute(0, 1, 3, 4, 2)
35
36 tensor = torch.unbind(tensor, dim=1)
37 return tensor
38
39def normalize_single(d):
40 # d is a whatever shape torch tensor

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected