问题描述
下面的代码是摘自https://blog.paperspace.com/how-to-implement-a-yolo-v3-object-detector-from-scratch-in-pytorch-part-3/的摘录,对于它要实现的目标,我感到困惑。
grid = np.arange(grid_size)
a,b = np.meshgrid(grid,grid)
x_offset = torch.FloatTensor(a).view(-1,1)
y_offset = torch.FloatTensor(b).view(-1,1)
if CUDA:
x_offset = x_offset.cuda()
y_offset = y_offset.cuda()
x_y_offset = torch.cat((x_offset,y_offset),1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
我尝试了当grid_size = 3时的情况,并输出:
tensor([[0.,1.],[2.,0.],[1.,2.],[0.,2.]])
我不太清楚这里的模式。根据给定链接中的描述,我认为我真的应该期望像这样:
tensor([[0,0],[0,1],2],...]])
解决方法
如果您希望显示第二个输出,只需更改
>>> len(list(boto3.resource('s3').Bucket('example-bucket').objects.all()))
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied
>>> len(list(boto3.resource('s3').Bucket('example-bucketzz').objects.all()))
botocore.errorfactory.NoSuchBucket: An error occurred (NoSuchBucket) when calling the ListObjects operation: The specified bucket does not exist
到
x_y_offset = (
torch.cat((x_offset,y_offset),1).repeat(1,num_anchors).view(-1,2).unsqueeze(0)
)
它只与meshgrid输出的顺序有关。