Created
November 7, 2020 00:19
-
-
Save gkarthik/144c7ea44372172d8e6b9b0fe2b214c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
nentity = 100 | |
nhidden = 20 | |
nrelations = 10 | |
entity_embedding = np.random.uniform(-10, 10, (nentity, nhidden)) | |
relation_embedding = np.random.uniform(-1, 1, (nrelations, nhidden)) | |
# For every iteration | |
head = entity_embedding[0] # Pick any entity based negative or positive samples per batch | |
tail = entity_embedding[10] # Pick any entity based negative or positive samples per batch | |
relation = relation_embedding[0] # Pick a relation that connects head and tail entities based on positive or negative samples | |
# Compute score using transE embedding | |
score = (head+relation) - tail | |
# Minimize loss etc.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment