【发布时间】:2017-05-05 14:37:42
【问题描述】:
我正在使用阈值向量在 2d numpy 数组中逐行创建二进制值。示例代码如下:
import numpy as np
x = np.random.rand(100000, 200)
coef = np.random.random(x.shape[1])
x = np.array([[1 if x[i,j]>=coef[j] else 0 for j in range(x.shape[1])] for i in range(x.shape[0])])
有没有办法让它更快?
【问题讨论】: