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)
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)
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)
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)
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)
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)
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)
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)