Hello,
I am currently creating a Heterogeneous Graph composed of Nodes for users and job listings. Edges are drawn based on whether an interview has been scheduled between the user and the job listing.
I was successful in training with the Training Data. The problem I’m facing now is not knowing how to use this model to predict edges for all job listings in relation to a new user and to calculate the probabilities.
For one particular user’s Node, I’m creating a graph with edges connecting this user to all job listings (User: 1, Work: 59039), resulting in a graph like this.
import dgl
# define node number
num_users = 1
num_works = 59039
# make node ID
user_ids = torch.arange(num_users)
work_ids = torch.arange(num_works)
src_nodes = torch.zeros(num_works, dtype=torch.long)
dst_nodes = torch.arange(num_works)
# define edge type
edge_type_forward = ('user', 'mendan', 'work')
edge_type_backward = ('work', 'mendan', 'user')
# make graph
graph = dgl.heterograph({
edge_type_forward: (src_nodes, dst_nodes),
edge_type_backward: (dst_nodes, src_nodes),
})
⇒
Graph(num_nodes={‘user’: 1, ‘work’: 59039},
num_edges={(‘user’, ‘mendan’, ‘work’): 59039, (‘work’, ‘mendan’, ‘user’): 59039},
metagraph=[(‘user’, ‘work’, ‘mendan’), (‘work’, ‘user’, ‘mendan’)])
I then adopted a method to feed this graph into the trained model.
node_features_eval = {'user': new_user_feature , 'work': work_features}
model.eval()
k=1
with torch.no_grad(): # Deactivate gradients for the following code
# negative_graph_eval = construct_negative_graph(graph, k, ('user', 'mendan', 'work'))
pos_score_eval, neg_score_eval = model(graph, graph, node_features_eval, ('user', 'mendan', 'work'))
However, the outcome was that the prediction scores for all the edges turned out to be the same as below.
tensor([[-18.2616],
[-18.2616],
[-18.2616],
…,
[-18.2616],
[-18.2616],
[-18.2616]])
My question is, is my approach correct?
or is there any other way to predict edge score for new users??
Thank you in advance.