lmcinnes / lmcinnes/umap

Parametric UMAP changing n_components

Open
#586 9 comments 1 reaction 1 assignee View on GitHub

@leriomaggio is already working on this.

Since Feb 16, 2021.

Dominant language
Python
Stars
8.3k
Forks
871
Avg merge
1d 13h
Merged PRs (30d)
5

Description

Hello,

I'm new with parametric UMAP, also i need to perform dimensionality reduction in a dataset and obtain 8 dimensional feature vector.

I understand that the parameter that i have to chage is n_components

I already change n_components from 2 to 8

# define the network
import tensorflow as tf
dims = (28, 28, 1)
n_components = 8
encoder = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=dims),
tf.keras.layers.Conv2D(
filters=32, kernel_size=3, strides=(2, 2), activation="relu", padding="same"
),
tf.keras.layers.Conv2D(
filters=64, kernel_size=3, strides=(2, 2), activation="relu", padding="same"
),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(units=256, activation="relu"),
tf.keras.layers.Dense(units=256, activation="relu"),
tf.keras.layers.Dense(units=n_components),
])
encoder.summary()

##############

but an error appears:

/usr/local/lib/python3.6/dist-packages/umap/umap_.py in fit(self, X, y)
2560 # Might be worth moving this into simplicial_set_embedding or _fit_embed_data
2561 disconnected_vertices = np.array(self.graph_.sum(axis=1)).flatten() == 0
-> 2562 self.embedding_[disconnected_vertices] = np.full(self.n_components, np.nan)
2563
2564 self.embedding_ = self.embedding_[inverse]

ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,8)

Please help me.

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.