Hi Prof. Peixoto,
OS: ubuntu 22
python: 3.12
gt: 2.96
There are two problems:
First.
The problem is OverlapBlockState()
gets stuck at a single state after a few MCMC sweeps.
MWE:
import numpy as np
import graph_tool.all as gt
import pickle
import matplotlib.pyplot as plt
with open(f'graph.pkl', 'rb') as f:
[g] = pickle.load(f)
state = gt.OverlapBlockState
state_args = dict(deg_corr=False, B=112)
state = gt.minimize_blockmodel_dl(g, state, state_args)
b_old = np.array(list(state.b))
dS, nmoves = 0, 0
for i in tqdm(range(10)):
ret = state.multiflip_mcmc_sweep(beta=np.inf, niter=args.niter)
dS += ret[0]
nmoves += ret[1]
b_cur = np.array(list(state.b))
print(dS, nmoves, b_old - b_cur)
plt.plot(b_old - b_cur)
I was using mcmc_equilibrate()
and traced the problem here.
The problem does not seem to occur for deg_corr=True
.
Is this expected?
I also verified this behavior with another simpler real world graph: g = gt.collection.data['polbooks']
.
Second.
I observed this behavior with both deg_corr=True/False
.
My goal was to collect partitions from the posterior.
So I thought of an alternative: I could use the heuristic gt.minimize_blockmodel_dl()
multiple times and collect partitions; a cheap approximation of the posterior.
If this alternative sounds reasonable—because I am still collecting partitions from the posterior—can I find posterior modes using gt.ModeClusterState()
and then find the total evidence of the model?
When I did that, the total evidence
value didn’t make sense.
I followed the documentation to compute L
as having these three components: -mean(dls), logB, H
. But H
value was too high even for a posterior with a single mode.
Many thanks,
Govinda
graph.pkl (27.5 KB)