Get the mean of a 2D tensor for each column - PyTorch Forums
https://discuss.pytorch.org/t/get-the-mean-of-a-2d-tensor-for-each...28.12.2021 · Hello, I want to know what is the most simple way to get the mean of the matrix along each column, namely my tensor only has two dimensions with shape (m X n). For example, if I have a tensor object T = torch.FloatTensor([[2.6, 5], [1.7, 6], [3.2, 7], [2.1, 8]]) I want some function that could return a tensor object as following ([2.4, 6.5]) I know I could do with for …
How to select tensor's columns by mask? - PyTorch Forums
https://discuss.pytorch.org/t/how-to-select-tensors-columns-by-mask/2114514.07.2018 · For example I have 3d tensor like this: a = torch.ones((3, 3, 3)) a[:, 1, 1] = 2 a[:, 2, 2] = 5 And I have a 2d “mask” like this: b = torch.zeros((3, 3)) b[1, 1] = 1 b[2, 2] = 1 And I want to get a list of 3d vectors from ‘a’ by mask ‘b’: the output should contain two vectors: [[2, 2, 2], [5, 5, 5]] I tried to use some constructions like torch.masked_select, but it always return 1d ...