def _e_step(psamples, W_list, b_list, n_steps=100, eps=1e-05):
 depth = len(psamples)
 def mf_iteration(*psamples):
  new_psamples = [p for p in psamples]
  for i in xrange(1, depth, 2):
   new_psamples[i] = hi_given(psamples, i, W_list, b_list)
  for i in xrange(2, depth, 2):
   new_psamples[i] = hi_given(psamples, i, W_list, b_list)
  score = 0.0
  for i in xrange(1, depth):
   score = T.maximum(T.mean(abs((new_psamples[i] - psamples[i]))), score)
  return (new_psamples, theano.scan_module.until((score < eps)))
 (new_psamples, updates) = scan(mf_iteration, outputs_info=psamples, n_steps=n_steps)
 return [x[(-1)] for x in new_psamples]

def _e_step ( psamples , W_list , b_list , n_steps = 100 , eps = 1e-05 ) : depth = len ( psamples ) def mf_iteration ( * psamples ) : new_psamples = [ p for p in psamples ] for i in xrange ( 1 , depth , 2 ) : new_psamples [ i ] = hi_given ( psamples , i , W_list , b_list ) for i in xrange ( 2 , depth , 2 ) : new_psamples [ i ] = hi_given ( psamples , i , W_list , b_list ) score = 0.0 for i in xrange ( 1 , depth ) : score = T . maximum ( T . mean ( abs ( ( new_psamples [ i ] - psamples [ i ] ) ) ) , score ) return ( new_psamples , theano . scan_module . until ( ( score < eps ) ) ) ( new_psamples , updates ) = scan ( mf_iteration , outputs_info = psamples , n_steps = n_steps ) return [ x [ ( - 1 ) ] for x in new_psamples ]
performs n_steps of mean-field inference parameters psamples : array-like object of theano shared variables state of each layer of the dbm .