TensorFlow数据归一化

TensorFlow数据归一化

1. tf.nn.l2_normalize
    - l2_normalize(x, dim, epsilon=1e-12,name=None)
    - output = x / sqrt(max(sum(x**2), epsilon))
2.使用scikit-learn进行归一化(**numpyarray**)
    ```
    min_max_scaler = preprocessing.MinMaxScaler()
    standar_scaler = preprocessing.StandardScaler()
    feature_1_scaled = standar_scaler.fit_transform(feature_1)
    feature_3_scaled = min_max_scaler.fit_transform(feature_1)
    ```
3. tensor与numpyarray相互转换
    - tf.convert_to_tensor(img.eval())
    - print(type(tf.Session().run(tf.constant([1,2,3])))) --**

People typically use scikit-learn (StandardScaler) for standardizing data before they train their models on TensorFlow.

def normalize(train, test):
    mean, std = train.mean(), test.std()
    train = (train - mean) / std
    test = (test - mean) / std
    return train, test

你可能感兴趣的:(深度学习,数据)