def test_generator_constructor(self): generator = FullBatchLinkGenerator(self.G) assert generator.Aadj.shape == (self.N, self.N) assert generator.features.shape == (self.N, self.n_feat)
def test_generator_flow_targets_not_iterator(self): generator = FullBatchLinkGenerator(self.G) link_ids = list(self.G.edges())[:3] link_targets = 1 with pytest.raises(TypeError): generator.flow(link_ids, link_targets)
def test_generator_constructor_hin(self): feature_sizes = {"t1": 1, "t2": 1} Ghin, nodes_type_1, nodes_type_2 = example_hin_3(feature_sizes) with pytest.raises(TypeError): generator = FullBatchLinkGenerator(Ghin)
def test_generator_constructor_wrong_G_type(self): with pytest.raises(TypeError): generator = FullBatchLinkGenerator(nx.Graph())
edges = pd.DataFrame({"source": Source, "target": Target, "weight": Value}) Gs = sg.StellarGraph(nodes=nodes, edges=edges) import tensorflow as tf # Define an edge splitter on the original graph G: edge_splitter_train = EdgeSplitter(Gs) # Randomly sample a fraction p=0.1 of all positive links, and same number of negative links # reduced graph G_train with the sampled links removed: G_train, edge_ids_train, edge_labels_train = edge_splitter_train.train_test_split( p=0.1, method="global", keep_connected=True) epochs = 300 train_gen = FullBatchLinkGenerator(G_train, method="gcn", weighted=True) train_flow = train_gen.flow(edge_ids_train, edge_labels_train) layer_sizes = [20, 20] gcn = GCN(layer_sizes=layer_sizes, activations=["elu", "softmax"], generator=train_gen, dropout=0.5) x_inp, x_out = gcn.in_out_tensors() prediction = LinkEmbedding(activation="relu", method="ip")(x_out) model = keras.Model(inputs=x_inp, outputs=prediction)
def test_generator_constructor_hin(self): Ghin = example_hin_1({}) with pytest.raises(TypeError): generator = FullBatchLinkGenerator(Ghin)