为了实时绘制python中的COM端口数据,我需要创建一个固定长度的数组,如果接收到新值,它将保持最后一个索引,当数组被填充时,在下次更新时,它会在第一个索引处转储值.换句话说,它将最新值保留在最后一个索引处并在第一个索引处清空值(以保持长度固定)
我已将 ReLu 导数实现为:
def relu_derivative(x):
return (x>0)*np.ones(x.shape)
Run Code Online (Sandbox Code Playgroud)
我也试过:
def relu_derivative(x):
x[x>=0]=1
x[x<0]=0
return x
Run Code Online (Sandbox Code Playgroud)
X 的大小=(3072,10000)。但是计算需要很多时间。有没有其他优化的解决方案?
python numpy machine-learning deep-learning activation-function