t = torch.Tensor([1, 0, 0, 1])
:
weights
我想形成一个新的张量
weights = {0: 0.1, 1: 0.9}
new_t
t
new_t = torch.Tensor([0.9, 0.1, 0.1, 0.9])
,还有其他选择吗?
如果您将重量转换为张量,则可以直接索引