【发布时间】:2022-01-23 06:01:31
【问题描述】:
我在 python 中有以下代码 sn-p(它是函数的一部分):
def decode_netout(netout, anchors, obj_thresh, net_h, net_w):
# print("netout print: ", netout.shape, netout[0])
grid_h, grid_w = netout.shape[:2]
nb_box = 3
netout = netout.reshape((grid_h, grid_w, nb_box, -1))
nb_class = netout.shape[-1] - 5
boxes = []
netout[..., :2] = _sigmoid(netout[..., :2])
netout[..., 4:] = _sigmoid(netout[..., 4:])
netout[..., 5:] = netout[..., 4][..., np.newaxis] * netout[..., 5:]
netout[..., 5:] *= netout[..., 5:] > obj_thresh
这里的 netout 是包含 13、13、255 的数组,它被转换为 13、13、3、85。 现在考虑以下陈述,
netout[..., :2] = _sigmoid(netout[..., :2])
如果我需要将此功能代码转换为 C++ 等效代码,编写此代码的最佳方法是什么。在 C++ 中,netout 是一个浮点数组。 谢谢并恭祝安康, -苏尼尔·普拉尼克
【问题讨论】:
-
在 C++ 中,
netout只是长度为 43095 的一维向量吗?如果是这样,那么重塑只是以不同的方式进行维度计算的问题。向量运算都会变成循环,除非你使用像eigen这样的数学库。
标签: python c++ arrays dimension