未验证 提交 5fdec3ed 编写于 作者: K Kaipeng Deng 提交者: GitHub

fix test_metrics accuracy. test=develop (#26358)

上级 a83e0f26
......@@ -40,7 +40,8 @@ def accuracy(pred, label, topk=(1, )):
def convert_to_one_hot(y, C):
oh = np.random.random((y.shape[0], C)).astype('float32') * .5
oh = np.random.choice(np.arange(C), C, replace=False).astype('float32') / C
oh = np.tile(oh[np.newaxis, :], (y.shape[0], 1))
for i in range(y.shape[0]):
oh[i, int(y[i])] = 1.
return oh
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册