How is Embedding.weight.data.cpu().numpy() used?


(Changlin Zhang) #1

I am reading a implementation of TranE model but don’t understand the following part:
After training, it uses the following code as input to evaluation part:

ent_embeddings = model.ent_embeddings.weight.data.cpu().numpy()
rel_embeddings = model.rel_embeddings.weight.data.cpu().numpy()
tem_embeddings = model.tem_embeddings.weight.data.cpu().numpy()

In evaluation part, it uses:

    h_e = ent_embeddings[headList]
    t_e = ent_embeddings[tailList]
    r_e = rel_embeddings[relList]

Why is it used like that? I think ent_embeddings are just weights instead of operations?
And if I want to use a LSTM model to generate r_e, I couldn’t use lstm_embeddings = model.lstm.weight.data.cpu().numpy(). But is there similar ways I could use LSTM to operate on CPU?