index_fill_(dim, index, val) 함수 - DonghoonPark12/ssd.pytorch GitHub Wiki
self 텐서를 주어진 index에 따라 val값으로 채운다.
import torch
x = tensor([1, 2, 3], [4, 5, 6], [7, 8, 9](/DonghoonPark12/ssd.pytorch/wiki/1,-2,-3],-[4,-5,-6],-[7,-8,-9), dtype=float)
index = tensor([0, 2])
x.index_fill_(1, index, -1)
해설
dim '1'이라 하면 열을 기준으로 채우겠다는 뜻이다. 열의 0번, 2번 인덱스에 -1로 채운다.
[Reference]
텐서 내장 함수 참고(https://pytorch.org/docs/stable/tensor)
Pytorch 백과사전(https://pytorch.org/docs/stable/genindex.html)