I implemented the following code to get the best model using the pipeline in pykeen, and now want to get the embeddings of new triples using best_model. How can this be done?
model_types = ['TransR', 'CompGCN', 'ConvE']
losses = ['pointwisehinge', 'pairwisehinge']
for model_ch in model_types:
for loss_ch in losses:
try:
result = pipeline(
model=model_ch,
loss=loss_ch,
training=training,
testing=testing,
validation=validation,
model_kwargs=dict(embedding_dim=10, random_seed=12),
optimizer_kwargs=dict(lr=0.025),
training_kwargs=dict(num_epochs=100, use_tqdm_batch=False),
)
l = result.losses
if min(l) < least_loss:
least_loss = min(l)
best_model = result.model
print("Model type = " + model_ch)
print("Loss type = " + loss_ch)`
I tried using best_model.entity_representations[0]._embeddings.weight to extract the weights but do not know how to get the embeddings of new triples.