too many indices for tensor of dimension 3
原因还未找到,只是感觉把维度换成一模一样就不报错了,或者换成另一片博文中的也可以。
too many indices for tensor of dimension
tconf是80*3
best_n也是80*3
gy是80
最后报错:too many indices for tensor of dimension 1
tconf[best_n][np.array(gy), np.asarray(gx)] = 1
import torch
import numpy as np
# 80 10 5 3:4
# 80 3 11 11
import copy
a = torch.linspace(-4, -1, steps=4)
a = torch.linspace(0, 1, steps=2).repeat(16,1).view(16,2)
b = torch.linspace(1, 256, steps=256).view(8,8, 4)
print(np.array(a))
print(b<5)
#取单个值,
# a=[[0,0,0,1],[0,0,0,2]]#维度变了
b[np.asarray(a)]=0
print(b)