Deep Graph Infomax (DGI) learns node embeddings without labels by teaching a discriminator to tell real node embeddings from embeddings of a corrupted graph. A is a symmetric 0/1 adjacency matrix without self-loops and X the (N, F) features. Use the normalised adjacency with the degree matrix of .
corrupt(X, perm): the row-permuted features X[perm] (the graph structure stays the same).
gcn_encode(A, X, W): one GCN layer .
readout(Z): the summary vector .
discriminator(Z, s, Wb): the probabilities for every row of Z.
dgi_loss(Z_pos, Z_neg, s, Wb): the binary cross-entropy averaged over all terms, with label 1 for the rows of Z_pos and 0 for the rows of Z_neg, all scored against the same summary s of the real graph (as in the original DGI). Compute it from the logits stably and return a Python float.