Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Parametric UMAP to support torch backend. #1123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

torch working

b6b41fe
Select commit
Loading
Failed to load commit list.
Open

Update Parametric UMAP to support torch backend. #1123

torch working
b6b41fe
Select commit
Loading
Failed to load commit list.
Azure Pipelines / lmcinnes.umap failed May 17, 2024 in 31m 7s

Build #20240517.1 had test failures

Details

Tests

  • Failed: 80 (3.21%)
  • Passed: 1,764 (70.67%)
  • Other: 652 (26.12%)
  • Total: 2,496
Code coverage

  • 3076 of 5057 lines covered (60.83%)

Annotations

Check failure on line 297 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

Build log #L297

6 test(s) failed, 208 test(s) collected.

Check failure on line 738 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

Build log #L738

Cmd.exe exited with code '1'.

Check failure on line 295 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

Build log #L295

7 test(s) failed, 208 test(s) collected.

Check failure on line 789 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

Build log #L789

Bash exited with code '1'.

Check failure on line 1 in umap/tests/test_parametric_umap.py::test_create_model

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

umap/tests/test_parametric_umap.py::test_create_model

moon_dataset = array([[-7.92499569e-02,  9.96854776e-01],
       [ 9.95471923e-01,  9.50560433e-02],
       [ 1.84125353e+00, -4.0640....75819158e-02,  9.98867339e-01],
       [-7.86053095e-01,  6.18158986e-01],
       [ 1.01586596e+00, -4.99874128e-01]])

    @tf_only
    def test_create_model(moon_dataset):
        """test a simple parametric UMAP network"""
        embedder = ParametricUMAP()
>       embedding = embedder.fit_transform(moon_dataset)

umap/tests/test_parametric_umap.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
umap/parametric_umap.py:164: in fit_transform
    return super().fit_transform(X, y)
umap/umap_.py:2891: in fit_transform
    self.fit(X, y, force_all_finite)
umap/parametric_umap.py:149: in fit
    return super().fit(X, y)
umap/umap_.py:2784: in fit
    self.embedding_, aux_data = self._fit_embed_data(
umap/parametric_umap.py:299: in _fit_embed_data
    history = self.parametric_model.fit(
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:122: in error_handler
    raise e.with_traceback(filtered_tb) from None
umap/parametric_umap.py:1002: in compute_loss
    umap_loss = self._umap_loss(y_pred)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UMAPModel name=umap_model, built=True>
y_pred = {'embedding_from': <tf.Tensor 'umap_model_1/sequential_3/z_1/Add:0' shape=(200, 2) dtype=float32>, 'embedding_to': <tf.Tensor 'umap_model_1/sequential_1/z_1/Add:0' shape=(200, 2) dtype=float32>}
repulsion_strength = 1.0

    def _umap_loss(self, y_pred, repulsion_strength=1.0):
        # split out to/from
        embedding_to = y_pred["embedding_to"]
        embedding_from = y_pred["embedding_from"]
    
        # get negative samples
        embedding_neg_to = ops.repeat(embedding_to, self.negative_sample_rate, axis=0)
        repeat_neg = ops.repeat(embedding_from, self.negative_sample_rate, axis=0)
    
        repeat_neg_batch_dim = ops.shape(repeat_neg)[0]
    
        if keras.config.backend() in ("tensorflow", "jax"):
>           shuffled_indices = tf.random.shuffle(
                ops.arange(repeat_neg_batch_dim), seed=self.seed_generator
            )
E           TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

umap/parametric_umap.py:1033: TypeError
Raw output
/home/vsts/work/1/s/umap/parametric_umap.py:1033: TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

Check failure on line 1 in umap/tests/test_parametric_umap.py::test_global_loss

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

umap/tests/test_parametric_umap.py::test_global_loss

moon_dataset = array([[-7.92499569e-02,  9.96854776e-01],
       [ 9.95471923e-01,  9.50560433e-02],
       [ 1.84125353e+00, -4.0640....75819158e-02,  9.98867339e-01],
       [-7.86053095e-01,  6.18158986e-01],
       [ 1.01586596e+00, -4.99874128e-01]])

    @tf_only
    def test_global_loss(moon_dataset):
        """test a simple parametric UMAP network"""
        embedder = ParametricUMAP(global_correlation_loss_weight=1.0)
>       embedding = embedder.fit_transform(moon_dataset)

umap/tests/test_parametric_umap.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
umap/parametric_umap.py:164: in fit_transform
    return super().fit_transform(X, y)
umap/umap_.py:2891: in fit_transform
    self.fit(X, y, force_all_finite)
umap/parametric_umap.py:149: in fit
    return super().fit(X, y)
umap/umap_.py:2784: in fit
    self.embedding_, aux_data = self._fit_embed_data(
umap/parametric_umap.py:299: in _fit_embed_data
    history = self.parametric_model.fit(
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:122: in error_handler
    raise e.with_traceback(filtered_tb) from None
umap/parametric_umap.py:1002: in compute_loss
    umap_loss = self._umap_loss(y_pred)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UMAPModel name=umap_model, built=True>
y_pred = {'embedding_from': <tf.Tensor 'umap_model_1/sequential_1_3/z_1/Add:0' shape=(200, 2) dtype=float32>, 'embedding_to': <tf.Tensor 'umap_model_1/sequential_1_1/z_1/Add:0' shape=(200, 2) dtype=float32>}
repulsion_strength = 1.0

    def _umap_loss(self, y_pred, repulsion_strength=1.0):
        # split out to/from
        embedding_to = y_pred["embedding_to"]
        embedding_from = y_pred["embedding_from"]
    
        # get negative samples
        embedding_neg_to = ops.repeat(embedding_to, self.negative_sample_rate, axis=0)
        repeat_neg = ops.repeat(embedding_from, self.negative_sample_rate, axis=0)
    
        repeat_neg_batch_dim = ops.shape(repeat_neg)[0]
    
        if keras.config.backend() in ("tensorflow", "jax"):
>           shuffled_indices = tf.random.shuffle(
                ops.arange(repeat_neg_batch_dim), seed=self.seed_generator
            )
E           TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

umap/parametric_umap.py:1033: TypeError
Raw output
/home/vsts/work/1/s/umap/parametric_umap.py:1033: TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

Check failure on line 1 in umap/tests/test_parametric_umap.py::test_inverse_transform

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

umap/tests/test_parametric_umap.py::test_inverse_transform

moon_dataset = array([[-7.92499569e-02,  9.96854776e-01],
       [ 9.95471923e-01,  9.50560433e-02],
       [ 1.84125353e+00, -4.0640....75819158e-02,  9.98867339e-01],
       [-7.86053095e-01,  6.18158986e-01],
       [ 1.01586596e+00, -4.99874128e-01]])

    @tf_only
    def test_inverse_transform(moon_dataset):
        """tests inverse_transform"""
    
        def norm(x):
            return (x - np.min(x)) / (np.max(x) - np.min(x))
    
        X = norm(moon_dataset)
        embedder = ParametricUMAP(parametric_reconstruction=True)
>       Z = embedder.fit_transform(X)

umap/tests/test_parametric_umap.py:56: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
umap/parametric_umap.py:164: in fit_transform
    return super().fit_transform(X, y)
umap/umap_.py:2891: in fit_transform
    self.fit(X, y, force_all_finite)
umap/parametric_umap.py:149: in fit
    return super().fit(X, y)
umap/umap_.py:2784: in fit
    self.embedding_, aux_data = self._fit_embed_data(
umap/parametric_umap.py:299: in _fit_embed_data
    history = self.parametric_model.fit(
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:122: in error_handler
    raise e.with_traceback(filtered_tb) from None
umap/parametric_umap.py:1002: in compute_loss
    umap_loss = self._umap_loss(y_pred)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UMAPModel name=umap_model, built=True>
y_pred = {'embedding_from': <tf.Tensor 'umap_model_1/sequential_2_3/z_1/Add:0' shape=(200, 2) dtype=float32>, 'embedding_to': <...float32>, 'reconstruction': <tf.Tensor 'umap_model_1/sequential_3_1/reshape_1/Reshape:0' shape=(200, 2) dtype=float32>}
repulsion_strength = 1.0

    def _umap_loss(self, y_pred, repulsion_strength=1.0):
        # split out to/from
        embedding_to = y_pred["embedding_to"]
        embedding_from = y_pred["embedding_from"]
    
        # get negative samples
        embedding_neg_to = ops.repeat(embedding_to, self.negative_sample_rate, axis=0)
        repeat_neg = ops.repeat(embedding_from, self.negative_sample_rate, axis=0)
    
        repeat_neg_batch_dim = ops.shape(repeat_neg)[0]
    
        if keras.config.backend() in ("tensorflow", "jax"):
>           shuffled_indices = tf.random.shuffle(
                ops.arange(repeat_neg_batch_dim), seed=self.seed_generator
            )
E           TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

umap/parametric_umap.py:1033: TypeError
Raw output
/home/vsts/work/1/s/umap/parametric_umap.py:1033: TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

Check failure on line 1 in umap/tests/test_parametric_umap.py::test_custom_encoder_decoder

See this annotation in the file changed.

@azure-pipelines azure-pipelines / lmcinnes.umap

umap/tests/test_parametric_umap.py::test_custom_encoder_decoder

moon_dataset = array([[-7.92499569e-02,  9.96854776e-01],
       [ 9.95471923e-01,  9.50560433e-02],
       [ 1.84125353e+00, -4.0640....75819158e-02,  9.98867339e-01],
       [-7.86053095e-01,  6.18158986e-01],
       [ 1.01586596e+00, -4.99874128e-01]])

    @tf_only
    def test_custom_encoder_decoder(moon_dataset):
        """test using a custom encoder / decoder"""
        dims = (2,)
        n_components = 2
        encoder = tf.keras.Sequential(
            [
                tf.keras.layers.Input(shape=dims),
                tf.keras.layers.Flatten(),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(units=n_components, name="z"),
            ]
        )
    
        decoder = tf.keras.Sequential(
            [
                tf.keras.layers.Input(shape=(n_components,)),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(units=100, activation="relu"),
                tf.keras.layers.Dense(
                    units=np.product(dims), name="recon", activation=None
                ),
                tf.keras.layers.Reshape(dims),
            ]
        )
    
        embedder = ParametricUMAP(
            encoder=encoder,
            decoder=decoder,
            dims=dims,
            parametric_reconstruction=True,
            verbose=True,
        )
>       embedding = embedder.fit_transform(moon_dataset)

umap/tests/test_parametric_umap.py:98: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
umap/parametric_umap.py:164: in fit_transform
    return super().fit_transform(X, y)
umap/umap_.py:2891: in fit_transform
    self.fit(X, y, force_all_finite)
umap/parametric_umap.py:149: in fit
    return super().fit(X, y)
umap/umap_.py:2784: in fit
    self.embedding_, aux_data = self._fit_embed_data(
umap/parametric_umap.py:299: in _fit_embed_data
    history = self.parametric_model.fit(
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:122: in error_handler
    raise e.with_traceback(filtered_tb) from None
umap/parametric_umap.py:1002: in compute_loss
    umap_loss = self._umap_loss(y_pred)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <UMAPModel name=umap_model, built=True>
y_pred = {'embedding_from': <tf.Tensor 'umap_model_1/sequential_4_3/z_1/Add:0' shape=(200, 2) dtype=float32>, 'embedding_to': <...oat32>, 'reconstruction': <tf.Tensor 'umap_model_1/sequential_5_1/reshape_1_1/Reshape:0' shape=(200, 2) dtype=float32>}
repulsion_strength = 1.0

    def _umap_loss(self, y_pred, repulsion_strength=1.0):
        # split out to/from
        embedding_to = y_pred["embedding_to"]
        embedding_from = y_pred["embedding_from"]
    
        # get negative samples
        embedding_neg_to = ops.repeat(embedding_to, self.negative_sample_rate, axis=0)
        repeat_neg = ops.repeat(embedding_from, self.negative_sample_rate, axis=0)
    
        repeat_neg_batch_dim = ops.shape(repeat_neg)[0]
    
        if keras.config.backend() in ("tensorflow", "jax"):
>           shuffled_indices = tf.random.shuffle(
                ops.arange(repeat_neg_batch_dim), seed=self.seed_generator
            )
E           TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'

umap/parametric_umap.py:1033: TypeError
Raw output
/home/vsts/work/1/s/umap/parametric_umap.py:1033: TypeError: unsupported operand type(s) for %: 'SeedGenerator' and 'int'