def __init__(self, graph, output_dim, features_num, batch_size, val_batch_size=None, test_batch_size=None, categorical_attrs_desc='', hidden_dim=16, in_drop_rate=0, hops_num=2, neighs_num=None, agg_type='gcn', full_graph_mode=False, unsupervised=False, neg_num=10, node_type='item', edge_type='relation'): super(GraphSage, self).__init__(graph, batch_size, full_graph_mode=full_graph_mode) self.features_num = features_num self.hidden_dim = hidden_dim self.in_drop_rate = in_drop_rate self.output_dim = output_dim self.neighs_num = neighs_num self.val_batch_size = val_batch_size if val_batch_size else batch_size self.test_batch_size = test_batch_size if test_batch_size else batch_size self.agg_type = agg_type self.hops_num = hops_num self.unsupervised = unsupervised self.neg_num = neg_num self.node_type = node_type self.edge_type = edge_type # construct EgoSpecs. categorical_attrs_num = len(categorical_attrs_desc) continuous_attrs_num = features_num - categorical_attrs_num src_spec = gl.FeatureSpec(continuous_attrs_num, categorical_attrs_num, labeled=not self.unsupervised) hop_spec = gl.HopSpec( gl.FeatureSpec(continuous_attrs_num, categorical_attrs_num)) self.src_ego_spec = gl.EgoSpec(src_spec, hops_spec=[hop_spec] * self.hops_num) # encoders. self.encoders = self._encoders()
def __init__(self, graph, walk_len, window_size, node_count, hidden_dim, neg_num, batch_size, s2h=False, ps_hosts=None, temperature=1.0, node_type='item', edge_type='relation'): super(DeepWalk, self).__init__(graph, batch_size) self.walk_len = walk_len self.window_size = window_size self.node_count = node_count self.hidden_dim = hidden_dim self.neg_num = neg_num self.s2h = s2h self.ps_hosts=ps_hosts self.temperature=temperature self.node_type = node_type self.edge_type = edge_type # construct EgoSpecs. self.ego_spec = gl.EgoSpec(gl.FeatureSpec(0, 0)) # encoders. self.encoders = self._encoders()
def __init__(self, graph, node_count, hidden_dim, neg_num, batch_size, s2h=False, ps_hosts=None, proximity='first_order', node_type='item', edge_type='relation'): super(LINE, self).__init__(graph, batch_size) self.node_count = node_count self.hidden_dim = hidden_dim self.neg_num = neg_num self.s2h = s2h self.proximity = proximity self.ps_hosts = ps_hosts self.node_type = node_type self.edge_type = edge_type # construct EgoSpecs. self.ego_spec = gl.EgoSpec(gl.FeatureSpec(0, 0)) # encoders. self.encoders = self._encoders()
def __init__(self, graph, output_dim, features_num, num_heads, batch_size, val_batch_size=None, test_batch_size=None, categorical_attrs_desc='', hidden_dim=16, in_drop_rate=0, attn_drop_rate=0, hops_num=2, neighs_num=None, full_graph_mode=False, node_type='item', edge_type='relation'): super(GAT, self).__init__(graph, batch_size, full_graph_mode=full_graph_mode) self.features_num = features_num self.categorical_attrs_desc = categorical_attrs_desc self.hops_num = hops_num self.hidden_dim = hidden_dim self.num_heads = num_heads self.in_drop_rate = in_drop_rate self.attn_drop_rate = attn_drop_rate self.output_dim = output_dim self.neighs_num = neighs_num self.val_batch_size = val_batch_size if val_batch_size else batch_size self.test_batch_size = test_batch_size if test_batch_size else batch_size self.node_type = node_type self.edge_type = edge_type # construct EgoSpecs. categorical_attrs_num = len(categorical_attrs_desc) continuous_attrs_num = features_num - categorical_attrs_num src_spec = gl.FeatureSpec(continuous_attrs_num, categorical_attrs_num, labeled=True) hop_spec = gl.HopSpec(gl.FeatureSpec(continuous_attrs_num, categorical_attrs_num), sparse=(self.neighs_num is None)) self.src_ego_spec = gl.EgoSpec(src_spec, hops_spec=[hop_spec] * self.hops_num) # encoders. self.encoders = self._encoders()
def __init__(self, graph, neg_num, batch_size, margin, entity_num, relation_num, hidden_dim, s2h=False, ps_hosts=None): super(TransE, self).__init__(graph, batch_size) self.margin = margin self.entity_num = entity_num self.relation_num = relation_num self.hidden_dim = hidden_dim self.s2h = s2h self.neg_num = neg_num self.ps_hosts = ps_hosts self.node_ego_spec = gl.EgoSpec(gl.FeatureSpec(1, 0)) # continuous features as edge ids. self.edge_ego_spec = gl.EgoSpec(gl.FeatureSpec(1, 0)) self.encoders = self._encoders()
def __init__(self, graph, batch_size, hidden_dim, output_dim, hops_num, u_neighs_num, i_neighs_num, u_features_num=0, u_categorical_attrs_desc='', i_features_num=0, i_categorical_attrs_desc='', neg_num=10, use_input_bn=True, act=tf.nn.leaky_relu, agg_type='gcn', need_dense=True, in_drop_rate=0.5, ps_hosts=None): super(BipartiteGraphSage, self).__init__(graph, batch_size) self.hops_num = hops_num self.neg_num = neg_num self.hidden_dim = hidden_dim self.output_dim = output_dim self.u_neighs_num = u_neighs_num self.i_neighs_num = i_neighs_num self.u_features_num = u_features_num self.u_categorical_attrs_desc = u_categorical_attrs_desc self.i_features_num = i_features_num self.i_categorical_attrs_desc = i_categorical_attrs_desc self.use_input_bn = use_input_bn self.act = act self.agg_type = agg_type self.need_dense = need_dense self.in_drop_rate = in_drop_rate self.ps_hosts = ps_hosts # construct EgoSpecs. u_categorical_attrs_num = len(u_categorical_attrs_desc) u_continuous_attrs_num = u_features_num - u_categorical_attrs_num i_categorical_attrs_num = len(i_categorical_attrs_desc) i_continuous_attrs_num = i_features_num - i_categorical_attrs_num u_spec = gl.FeatureSpec(u_continuous_attrs_num, u_categorical_attrs_num) i_spec = gl.FeatureSpec(i_continuous_attrs_num, i_categorical_attrs_num) u_hop_spec = gl.HopSpec(i_spec) i_hop_spec = gl.HopSpec(u_spec) u_hops_spec = [] # u-i-u-i-u... i_hops_spec = [] # i-u-i-u-i... for i in range(self.hops_num): if (i % 2) == 0: u_hops_spec.append(u_hop_spec) i_hops_spec.append(i_hop_spec) else: u_hops_spec.append(i_hop_spec) i_hops_spec.append(u_hop_spec) self.u_ego_spec = gl.EgoSpec(u_spec, hops_spec=u_hops_spec) self.i_ego_spec = gl.EgoSpec(i_spec, hops_spec=i_hops_spec) # encoders. self.encoders = self._encoders()