Skip to content

Commit

Permalink
use seeded random generation from np.random.Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciogtec committed Jul 13, 2024
1 parent e14f930 commit 06939eb
Showing 1 changed file with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -806,27 +806,27 @@ def _sample_from_ibp(K, alpha, sigma, c, seed=None):
return csr_matrix((data, (rowidx, colidx)), shape)


if __name__ == "__main__":
K, alpha, sigma, c, pie = 30, 3, 0.7, 5, 1.0
Z = _sample_from_ibp(K, alpha, sigma, c)

cic = (Z.transpose() @ Z).toarray()
adj = np.minimum(cic - np.diag(np.diag(cic)), 1)

# delete edges with prob 1 - exp(pi^)
prob = np.exp(-((1 - pie) ** 2))
triu_mask = np.triu(np.ones_like(adj), 1)
adj = np.random.binomial(1, prob, adj.shape) * adj * triu_mask
adj = adj + adj.T

g = nx.from_numpy_matrix(adj)
print("Number of edges:", g.number_of_edges())
print("Number of nodes:", g.number_of_nodes())

# Transform to a torch geometric data object
data = torch_geometric.utils.from_networkx(g)
data.x = torch.ones(data.num_nodes, 1)

# Lift the topology to a cell complex
lifting = LatentCliqueLifting(edge_prob_mean=0.99)
complex = lifting.lift_topology(data, verbose=True)
# if __name__ == "__main__":
# K, alpha, sigma, c, pie = 30, 3, 0.7, 5, 1.0
# Z = _sample_from_ibp(K, alpha, sigma, c)

# cic = (Z.transpose() @ Z).toarray()
# adj = np.minimum(cic - np.diag(np.diag(cic)), 1)

# # delete edges with prob 1 - exp(pi^)
# prob = np.exp(-((1 - pie) ** 2))
# triu_mask = np.triu(np.ones_like(adj), 1)
# adj = np.random.binomial(1, prob, adj.shape) * adj * triu_mask
# adj = adj + adj.T

# g = nx.from_numpy_matrix(adj)
# print("Number of edges:", g.number_of_edges())
# print("Number of nodes:", g.number_of_nodes())

# # Transform to a torch geometric data object
# data = torch_geometric.utils.from_networkx(g)
# data.x = torch.ones(data.num_nodes, 1)

# # Lift the topology to a cell complex
# lifting = LatentCliqueLifting(edge_prob_mean=0.99)
# complex = lifting.lift_topology(data, verbose=True)

0 comments on commit 06939eb

Please sign in to comment.