I have a variable called pts which is shaped [batch, ch, h, w]. This is a heatmap and I want to convert it to 2nd co-ordinates. The goal is, pts_o = heatmap_to_pts(pts) where pts_o will be [batch, ch, 2]. I have wrote this function so far,
def heatmap_to_pts(self, pts): <- pts [batch, 68, 128, 128]
pt_num = []
for i in range(len(pts)):
pt = pts[i]
if type(pt) == torch.Tensor:
d = torch.tensor(128) * get the
m = pt.view(68, -1).argmax(1) * indices
indices = torch.cat(((m / d).view(-1, 1), (m % d).view(-1, 1)), dim=1) * from heatmaps
pt_num.append(indices.type(torch.DoubleTensor) ) <- store the indices in a list
b = torch.Tensor(68, 2) * trying to convert
c = torch.cat(pt_num, out=b) *error* * a list of tensors with grad
c = c.reshape(68,2) * to a tensor like [batch, 68, 2]
return c
The error says "cat(): functions with out=... arguments don't support automatic differentiation, but one of the arguments requires grad.". It's unable to do the operations because tensors in pt_num requires grad".
How can I convert that list to a tensor?