如何在pytorch中交换x和y?
给定一个输出张量为 100 * 6(xmin,ymin,xmax,ymax,conf,class),如何在 pytorch 中得到一个 100 * 6(ymin,xmin,ymax,xmax,conf,class) 的张量? 例如,给定一个张量,
x = [[1,2,3,4,5,6],
[7,8,9,10,11,12]],
期望的结果是
y = [[2,1,4,3,5,6],
[8,7,10,9,11,12]]
Given a output tensor as 100 * 6(xmin,ymin,xmax,ymax,conf,class),how can I get a tensor as 100 * 6(ymin,xmin,ymax,xmax,conf,class) in pytorch?
For example, given a tensor
x = [[1,2,3,4,5,6],
[7,8,9,10,11,12]],
the desired results is
y = [[2,1,4,3,5,6],
[8,7,10,9,11,12]]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对此不太确定,但尝试 N6.T 或 N6.transpose?
I'm not completely sure about this, but try N6.T or N6.transpose?
您应该更清楚地指出,以便其他人理解什么是
x
和y
,它可能与轴混淆。但我明白你的意思,你想交换 ymin 和 xmin 位置以及 xmax、ymax 位置。因此,最简单的方法是创建一个时间张量 tempt_x 并通过切片交换值。
You should point clearer for others to understand what is
x
andy
, it can be confused with the axes. But I got your point, you want to swap ymin and xmin position and xmax, ymax position.Therefore, the easiest way is creating a temporal tensor
tempt_x
and swap value by slicing.