|
|
|
|
|
|
|
|
|
|
|
|
|
|
seq = np.zeros([maxlen], dtype=np.int32) |
|
|
seq = np.zeros([maxlen], dtype=np.int32) |
|
|
pos = np.zeros([maxlen], dtype=np.int32) |
|
|
pos = np.zeros([maxlen], dtype=np.int32) |
|
|
neg = np.zeros([maxlen*10], dtype=np.int32) |
|
|
|
|
|
|
|
|
neg = np.zeros([maxlen*30], dtype=np.int32) |
|
|
|
|
|
|
|
|
if len(user_train[user]) < maxlen: |
|
|
if len(user_train[user]) < maxlen: |
|
|
nxt_idx = len(user_train[user]) - 1 |
|
|
nxt_idx = len(user_train[user]) - 1 |
|
|
|
|
|
|
|
|
# support_negative_triples.append([seq[idx],curr_rel,neg[idx]]) |
|
|
# support_negative_triples.append([seq[idx],curr_rel,neg[idx]]) |
|
|
# support_negative_triples.append([seq[-1], curr_rel, neg[idx]]) |
|
|
# support_negative_triples.append([seq[-1], curr_rel, neg[idx]]) |
|
|
|
|
|
|
|
|
for idx in range(maxlen*10 - 1): |
|
|
|
|
|
support_negative_triples.append([seq[-1], curr_rel, neg[idx]]) |
|
|
|
|
|
|
|
|
# for idx in range(maxlen*30 - 1): |
|
|
|
|
|
# support_negative_triples.append([seq[-1], curr_rel, neg[idx]]) |
|
|
|
|
|
for j in range(30): |
|
|
|
|
|
for idx in range(maxlen-1): |
|
|
|
|
|
support_negative_triples.append([seq[idx], curr_rel, neg[j*maxlen + idx]]) |
|
|
|
|
|
|
|
|
query_triples.append([seq[-1],curr_rel,pos[-1]]) |
|
|
query_triples.append([seq[-1],curr_rel,pos[-1]]) |
|
|
negative_triples.append([seq[-1],curr_rel,neg[-1]]) |
|
|
negative_triples.append([seq[-1],curr_rel,neg[-1]]) |