Beispiel #1
0
    def test_unstandardize2(self):
        # Arrange
        X = np.random.randn(1e4, 1, 32, 32) * 10 + 12
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize(standardization_type='individual')
        ds.unstandardize()

        # Assert
        np.testing.assert_allclose(X, ds.X, atol=1e-5)
Beispiel #2
0
    def test_unstandardize2(self):
        # Arrange
        X = np.random.randn(1e4, 1, 32, 32) * 10 + 12
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize(standardization_type='individual')
        ds.unstandardize()

        # Assert
        np.testing.assert_allclose(X, ds.X, atol=1e-5)
Beispiel #3
0
    def test_unstandardize_global(self):
        # Arrange
        X = np.random.randn(1e4, 1, 32, 32) * 10 + 12
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize(standardization_type='global')
        ds.unstandardize()

        # Assert
        assert ds.mean.shape == ()
        np.testing.assert_allclose(ds.mean, 12, atol=1e-1)
        np.testing.assert_allclose(ds.std, 10, atol=1e-1)
Beispiel #4
0
    def test_unstandardize_global(self):
        # Arrange
        X = np.random.randn(1e4, 1, 32, 32) * 10 + 12
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize(standardization_type='global')
        ds.unstandardize()

        # Assert
        assert ds.mean.shape == ()
        np.testing.assert_allclose(ds.mean, 12, atol=1e-1)
        np.testing.assert_allclose(ds.std, 10, atol=1e-1)
Beispiel #5
0
    def test_unstandardize(self):
        # Arrange
        x1 = np.array([[0, 1, 0], [0, 1, 0], [0, 1, 0]])
        x2 = np.array([[1, 0, 1], [1, 0, 1], [1, 0, 1]])
        X = np.array([x1, x2])
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize()
        ds.unstandardize()

        # Assert
        np.testing.assert_allclose(ds.X[0].squeeze(), x1)
        np.testing.assert_allclose(ds.X[1].squeeze(), x2)
Beispiel #6
0
    def test_unstandardize(self):
        # Arrange
        x1 = np.array([[0, 1, 0],
                       [0, 1, 0],
                       [0, 1, 0]])
        x2 = np.array([[1, 0, 1],
                       [1, 0, 1],
                       [1, 0, 1]])
        X = np.array([x1, x2])
        y = np.arange(len(X))
        ds = DataSet(X, y)

        # Apply
        ds.standardize()
        ds.unstandardize()

        # Assert
        np.testing.assert_allclose(ds.X[0].squeeze(), x1)
        np.testing.assert_allclose(ds.X[1].squeeze(), x2)