0的任何次方等于1
1的任何次方等于1
所以规划化可以去掉
image=(image+1)/257
这个部分就需要17ms,p100机器上:
start=time.time()
inp_image = ((inp_image / 255. - self.mean) / self.std).astype(np.float32)
images = inp_image.transpose(2, 0, 1).reshape(1, 3, inp_height, inp_width)
print("guiyihua",time.time()-start)
归一化,这个不支持图像
def Normalize(data):
m = np.mean(data)
mx = max(data)
mn = min(data)
return [(float(i) - m) / (mx - mn) for i in data]
data=[1,255,2,23,150]
print(Normalize(data))
减均值,除以标准差
from sklearn import preprocessing
import numpy as np
# X = np.array([1,255,35])
X_scaled = preprocessing.scale(data)
print(X_scaled)