'Glove' object has no attribute 'vector_size'
时间: 2023-07-14 21:59:13 浏览: 82
I apologize for the confusion. It seems there was a misunderstanding in my previous response. The `vector_size` attribute is specific to Word2Vec models and not available directly in GloVe models.
In GloVe, the size of the word embeddings is determined by the dimensions of the embedding matrix. The shape of the embedding matrix represents the number of words in the vocabulary and the dimensionality of the embeddings.
To get the size of GloVe word embeddings, you can use the following code:
```python
import numpy as np
# Load GloVe word embeddings
glove_embeddings = np.load("your_glove_embeddings.npy")
# Get the embedding size
embedding_size = glove_embeddings.shape[1]
print("Embedding size:", embedding_size)
```
In this code, we assume that the GloVe word embeddings are saved in the "your_glove_embeddings.npy" file. We load the embeddings using `np.load` and then access the shape attribute to retrieve the size. The "shape[1]" represents the dimensionality of the embeddings.
Please make sure you have the `numpy` library installed and replace "your_glove_embeddings.npy" with the path to your GloVe embeddings file.
阅读全文