Exemplo n.º 1
0
def test_normalize_std_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    new_image = image.normalize_std()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(new_image.pixels), 1)
Exemplo n.º 2
0
def test_normalize_std_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    new_image = image.normalize_std()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(new_image.pixels), 1)
Exemplo n.º 3
0
def test_normalize_std_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_std()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(new_image.pixels), 1)
Exemplo n.º 4
0
def test_normalize_std_image():
    pixels = np.ones((3, 120, 120))
    pixels[0] = 0.5
    pixels[1] = 0.2345
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_std()
    assert_allclose(np.mean(new_image.pixels), 0, atol=1e-10)
    assert_allclose(np.std(new_image.pixels), 1)
Exemplo n.º 5
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    new_image = image.normalize_std(mode='per_channel')
    assert_allclose(np.mean(new_image.as_vector(keep_channels=True), axis=1),
                    0,
                    atol=1e-10)
    assert_allclose(np.std(new_image.as_vector(keep_channels=True), axis=1), 1)
Exemplo n.º 6
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_std(mode="per_channel")
    assert_allclose(np.mean(new_image.as_vector(keep_channels=True), axis=1), 0, atol=1e-10)
    assert_allclose(np.std(new_image.as_vector(keep_channels=True), axis=1), 1)
Exemplo n.º 7
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    new_image = image.normalize_std(mode='per_channel')
    assert_allclose(
        np.mean(new_image.as_vector(keep_channels=True), axis=1), 0,
        atol=1e-10)
    assert_allclose(
        np.std(new_image.as_vector(keep_channels=True), axis=1), 1)
Exemplo n.º 8
0
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        new_image = image.normalize_std(mode="per_channel")
    assert_allclose(np.mean(new_image.as_vector(keep_channels=True), axis=1),
                    0,
                    atol=1e-10)
    assert_allclose(np.std(new_image.as_vector(keep_channels=True), axis=1), 1)