Open linxkon opened 3 weeks ago
https://linxkon.github.io/Tensor%E5%9F%BA%E7%A1%803--%E5%BC%A0%E9%87%8F%E7%9A%84%E7%B4%A2%E5%BC%95%E4%B8%8E%E5%8F%98%E5%BD%A2.html
张量的索引操作
在操作张量时,经常要去获取某些元素进行处理或者修改操作,在这里需要了解torch中的索引操作。
准备数据: 12345678import torch# 随机生成数据data = torch.randint(0, 10, [4, 5])print(data)>>> tensor([[0, 7, 6, 5, 9], [6, 8
https://linxkon.github.io/Tensor%E5%9F%BA%E7%A1%803--%E5%BC%A0%E9%87%8F%E7%9A%84%E7%B4%A2%E5%BC%95%E4%B8%8E%E5%8F%98%E5%BD%A2.html
张量的索引操作
在操作张量时,经常要去获取某些元素进行处理或者修改操作,在这里需要了解torch中的索引操作。
准备数据: 12345678import torch# 随机生成数据data = torch.randint(0, 10, [4, 5])print(data)>>> tensor([[0, 7, 6, 5, 9], [6, 8