基本上,我试图根据随机索引将向量中的元素插入到矩阵中
size = 100000
answer_count = 4
num_range = int(1e4)
a = torch.randint(-num_range, num_range, size=(size, ))
b = torch.randint(-num_range, num_range, size=(size, ))
answers = torch.randint(-num_range, num_range, size=(size, answer_count))
for i in range(size): answers[i, np.random.randint(answer_count)] = a[i] + b[i]
我试过类似的东西
c = a + b
pos = torch.randint(answer_count, size=(size, ))
answers[:, pos] = c
但我肯定做错了什么
一只名叫tom的猫
相关分类