- def scaleToInputSize2(outputClasses, numClasses):
- validCount = 0;
- output = numpy.zeros(shape=(2,NUM_RESULTS))
- tmp_shape = outputClasses.shape
- score_class = map(lambda x: expit(x), outputClasses.flatten())
- score_class = list(score_class)
- score_class = np.array(score_class)
- score_class = score_class.reshape(tmp_shape)
- for i in range(0, NUM_RESULTS):
- topClassScore = -1000.0
- topClassScoreIndex = -1
- for j in range(1, numClasses):
- score = score_class[i][j]
- if (score > topClassScore) :
- topClassScoreIndex = j
- topClassScore = score
- if (topClassScore >= MIN_SCORE):
- output[0][validCount] = i
- output[1][validCount] = topClassScoreIndex
- validCount += 1
- return validCount, output
复制代码
troy 发表于 2019-12-27 18:01
参考该代码,使用lamba表达式,降低for循环导致的时间消耗。还有一种方式是直接计算出min_score所对应的out ...
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |