# Nan loss in Weighted Stochastic Block Model

**URL:** <https://discourse.edwardlib.org/t/nan-loss-in-weighted-stochastic-block-model/562>\
**Category:** General\
**Created:** [January 3, 2018, 4:59am UTC](https://discourse.edwardlib.org/t/nan-loss-in-weighted-stochastic-block-model/562 "2018-01-03T04:59:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keisukehonda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/keisukehonda/32/208_2.png) [@keisukehonda](https://discourse.edwardlib.org/u/keisukehonda)\
**Post date:** [January 3, 2018, 4:59am UTC](https://discourse.edwardlib.org/t/nan-loss-in-weighted-stochastic-block-model/562/1 "2018-01-03T04:59:35Z")

</div>

Hi,  
I tried Weighted Stochastic Block Model by example/sbm.py as refer.  
I choose model as Gamma-Poission conjugate model for weighted graph as follows.  
# MODEL

# Dirichlet-Multinomial conjugate model

gamma = Dirichlet(concentration=tf.ones([K]))  
Z = Multinomial(total\_count=1., probs=gamma, sample\_shape=N)

# Beta-Bernoulli conjugate model

#Pi = Beta(concentration0=tf.ones([K, K]), concentration1=tf.ones([K, K]))  
#X = Bernoulli(probs=tf.matmul(Z, tf.matmul(Pi, tf.transpose(Z))))

#Gamma-Poission conjugate model  
Pi = Gamma(concentration=tf.ones([K, K]), rate=tf.ones([K, K]))  
X = Poisson(rate = tf.matmul(Z, tf.matmul(Pi, tf.transpose(Z))))

# INFERENCE (EM algorithm)

qgamma = PointMass(params=tf.nn.softmax(tf.Variable(tf.random\_normal([K]))))  
qPi = PointMass(params=tf.nn.sigmoid(tf.Variable(tf.random\_normal([K, K]))))  
qZ = PointMass(params=tf.nn.softmax(tf.Variable(tf.random\_normal([N, K]))))

inference = ed.MAP({gamma: qgamma, Pi: qPi, Z: qZ}, data={X: X\_data})

n\_iter = c.n\_iter  
inference.initialize(n\_iter=n\_iter)

tf.global\_variables\_initializer().run()

for \_ in range(inference.n\_iter):  
info\_dict = inference.update()  
inference.print\_progress(info\_dict)  
inference.finalize()

With the result.  
1000/1000 [100%] ██████████████████████████████ Elapsed: 13s | Loss: nan  
Result / Cluster Number:  
[0 0 0 …, 0 0 0]

I would like to know some tips such as more stable model or ed.MAP algorithm.

Thanks for any help.
