def rbm_ais_pk_free_energy(rbmA_params, rbmB_params, beta, v_sample):
 def rbm_fe(rbm_params, v, b):
  (weights, visbias, hidbias) = rbm_params
  vis_term = (b * tensor.dot(v, visbias))
  hid_act = (b * (tensor.dot(v, weights) + hidbias))
  fe = ((- vis_term) - tensor.sum(tensor.log((1 + tensor.exp(hid_act))), axis=1))
  return fe
 fe_a = rbm_fe(rbmA_params, v_sample, (1 - beta))
 fe_b = rbm_fe(rbmB_params, v_sample, beta)
 return (fe_a + fe_b)

def rbm_ais_pk_free_energy ( rbmA_params , rbmB_params , beta , v_sample ) : def rbm_fe ( rbm_params , v , b ) : ( weights , visbias , hidbias ) = rbm_params vis_term = ( b * tensor . dot ( v , visbias ) ) hid_act = ( b * ( tensor . dot ( v , weights ) + hidbias ) ) fe = ( ( - vis_term ) - tensor . sum ( tensor . log ( ( 1 + tensor . exp ( hid_act ) ) ) , axis = 1 ) ) return fe fe_a = rbm_fe ( rbmA_params , v_sample , ( 1 - beta ) ) fe_b = rbm_fe ( rbmB_params , v_sample , beta ) return ( fe_a + fe_b )
computes the free-energy of visible unit configuration v_sample .