def load_yelp():
import scipy.sparse as sp
import pickle
path = "data/yelp_old/"
with open(path + '/meta_data.pkl', 'rb') as f:
data = pickle.load(f)
with open(path + '/labels.pkl', 'rb') as f:
labels = pickle.load(f)
with open(path + '/edges.pkl', 'rb') as f:
edges = pickle.load(f)
BS = sparse_mx_to_torch_sparse_tensor(edges['b-s']).float()._indices() # adj_list[0]._indices()
SB = sparse_mx_to_torch_sparse_tensor(edges['s-b']).float()._indices() # adj_list[1]._indices()
BL = sparse_mx_to_torch_sparse_tensor(edges['b-l']).float()._indices() # adj_list[0]._indices()
LB = sparse_mx_to_torch_sparse_tensor(edges['l-b']).float()._indices() # adj_list[1]._indices()
BU = sparse_mx_to_torch_sparse_tensor(edges['b-u']).float()._indices() # adj_list[0]._indices()
UB = sparse_mx_to_torch_sparse_tensor(edges['u-b']).float()._indices() # adj_list[1]._indices()
BS = sp.coo_matrix((np.ones(BS.shape[1]), (BS[0,:], BS[1, :]-3900)),
shape=(max(BS[0])+1, max(BS[1])- min(BS[1]) +1),
dtype=np.float32)
BL = sp.coo_matrix((np.ones(BL.shape[1]), (BL[0,:], BL[1, :]-3904)),
shape=(max(BL[0]) + 1, max(BL[1])- min(BL[1]) + 1), #- min(BL[1])
dtype=np.float32)
BU = sp.coo_matrix((np.ones(BU.shape[1]), (BU[0,:], BU[1, :]-2614)),
shape=(max(BU[0]) + 1, max(BU[1])- min(BU[1]) + 1), #- min(BU[1])
dtype=np.float32)
BSB = BS*BS.T
BUB = BU*BU.T
BLB = BL*BL.T#RB.transpose()*RU*RU.transpose()*RB
# BRKRB = RB.transpose()*RK*RK.transpose()*RB
BSB = pathsim(BSB)
BUB = pathsim(BUB)
BLB = pathsim(BLB)
sp.save_npz("{}{}".format(path, 'BSB.npz'), BSB)
sp.save_npz("{}{}".format(path, 'BUB.npz'), BUB)
sp.save_npz("{}{}".format(path, 'BLB.npz'), BLB)
根据边生成meta-path
最新推荐文章于 2024-11-04 21:51:40 发布