图像标准化

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012300744/article/details/81948375

传入图片数据 x,并返回标准化 Numpy 数组。值应该在 0 到 1 的范围内(含 0 和 1)。返回对象应该和 x 的形状一样。

def normalize(x):
    """
    Normalize a list of sample image data in the range of 0 to 1
    : x: List of image data.  The image shape is (32, 32, 3)
    : return: Numpy array of normalize data
    """
    # 方法一:
    return (x-np.min(x))/(np.max(x)-np.min(x))

    # 方法二:
    # return x/255

猜你喜欢

转载自blog.csdn.net/u012300744/article/details/81948375