torch.index_select — PyTorch 1.10.1 documentation
pytorch.org › docs › stabletorch.index_select(input, dim, index, *, out=None) → Tensor. Returns a new tensor which indexes the input tensor along dimension dim using the entries in index which is a LongTensor. The returned tensor has the same number of dimensions as the original tensor ( input ). The dim th dimension has the same size as the length of index; other ...
Assigning value at given target indices - PyTorch Forums
discuss.pytorch.org › t › assigning-value-at-givenJul 04, 2019 · Hi, Sorry if this question has been asked already. I couldn’t find a solution anywhere. I want to assign a value to a tensor at particular column indices. For instance, given a tensor t1 = [[0.3,0.4,0.5], [0.1,0.2, 0.8]] , indices = [1,2] and value = 1. I want to compute t2 such that t2 = [[0.3,1, 0.5], [0.1, 0.2, 1]]. Basically, I would like to do below with pytorch tensor indexing for i in ...