Pytorch随笔:gather函数

gather函数使用方法:
gather(dim,index)

dim = 0时,使用index填充行;dim = 1时,使用index填充列。
例如,index = tensor([[x,y,z]])
gather(dim=0,index)示意图为:
tensor([[(x,0),(y,1),(z,2)]])

gather(dim=1,index)示意图为:
tensor([[(0,x),(1,y),(2,z)]])

示例:
image
image

posted @ 2025-12-03 15:32  关注永雏塔菲谢谢喵  阅读(0)  评论(0)    收藏  举报