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

train_w.py Error, TypeError: can't convert np.ndarray of type numpy.object_ #57

Open
xiaoxiaoAurora opened this issue Dec 6, 2018 · 2 comments

Comments

@xiaoxiaoAurora
Copy link

xiaoxiaoAurora commented Dec 6, 2018

Hi, Liyuan, I encountered the following problem while running train_w.py,
Traceback (most recent call last):
File "/workspace/train.py", line 117, in
shrink_to_corpus=args.shrink_embedding)
File "/workspace/models/utils.py", line 457, in load_embedding_wlm
embedding_tensor_1 = torch.FloatTensor(pretrained_weight)
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: double, float, float16, int64, int32, and uint8.

And ,at the line 457, my coding as follows:
(1)
if not shrink_to_corpus:
pretrained_weight = np.asarray(outdoc_embedding_array)
embedding_tensor_1 = torch.from_numpy(pretrained_weight)
word_emb_len = embedding_tensor_0.size(1)
assert(word_emb_len == emb_len)

(2)
if not shrink_to_corpus:
embedding_tensor_1 = torch.Tensor(np.asarray(outdoc_embedding_array))
word_emb_len = embedding_tensor_0.size(1)
assert(word_emb_len == emb_len)

@Totoro-wen
Copy link

Have you solved this problem.

@wnismiddle
Copy link

I have encountered this problem before, but I just changed the embedding file.
The first line of the original embedding file shows vocab size and dimension, and the replaced file does not.
I don't know if this will help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants