Check if the embeddings have the correct shape.
(embeddings, docs)
| 49 | |
| 50 | |
| 51 | def check_embeddings_shape(embeddings, docs): |
| 52 | """Check if the embeddings have the correct shape.""" |
| 53 | if embeddings is not None: |
| 54 | if not any([isinstance(embeddings, np.ndarray), isinstance(embeddings, csr_matrix)]): |
| 55 | raise ValueError("Make sure to input embeddings as a numpy array or scipy.sparse.csr.csr_matrix. ") |
| 56 | else: |
| 57 | if embeddings.shape[0] != len(docs): |
| 58 | raise ValueError( |
| 59 | "Make sure that the embeddings are a numpy array with shape: " |
| 60 | "(len(docs), vector_dim) where vector_dim is the dimensionality " |
| 61 | "of the vector embeddings. " |
| 62 | ) |
| 63 | |
| 64 | |
| 65 | def check_is_fitted(topic_model): |
no outgoing calls