https://github.com/ShikamaruZhang/MANN
Raw File
Tip revision: 914f5ddb06a3853f2f60a09d156702154b084cb3 authored by HE ZHANG on 27 July 2018, 20:03:31 UTC
change-index
Tip revision: 914f5dd
Utils.py
import os.path

def build_path(path):
    for i in path:
        if not os.path.exists(i):
            os.makedirs(i)
    

def Normalize(X, axis, savefile= None):
    Xmean, Xstd = X.mean(axis=axis), X.std(axis=axis)
    for i in range(Xstd.size):
        if (Xstd[i]==0):
            Xstd[i]=1
    X = (X - Xmean) / Xstd
    if savefile != None:
        Xmean.tofile(savefile+'mean.bin')
        Xstd.tofile(savefile+'std.bin')
    return X
back to top