Pytorch Tips

人工智能炼丹师
2016-01-01 / 0 评论 / 3 阅读 / 正在检测是否收录...

1. scatter

target.scatter_(dim=1, index=index, src=src)
# 使用 for 循环模拟 scatter_ 操作
for i in range(src.shape[0]):
    for j in range(src.shape[1]):
        target[i, index[i, j]] = src[i, j]

target.scatter_(dim=0, index=index, src=src)
# 使用 for 循环模拟 scatter_ 操作
for i in range(src.shape[0]):
    for j in range(src.shape[1]):
        target[index[i, j], j] = src[i, j]
0

评论 (0)

取消
粤ICP备2021042327号