#NEWLINE# def expected_energy_vhs( self , V , H_hat , S_hat , var_s0_hat , var_s1_hat ) : #NEWLINE# #INDENT# '\n        .. todo::\n\n            WRITEME\n\n        This is not the same as negative expected log prob,\n        which includes the constant term for the log partition function\n        ' #NEWLINE# var_HS = ( ( H_hat * var_s1_hat ) + ( ( 1.0 - H_hat ) * var_s0_hat ) ) #NEWLINE# half = as_floatX ( 0.5 ) #NEWLINE# HS = ( H_hat * S_hat ) #NEWLINE# sq_HS = ( H_hat * ( var_s1_hat + T . sqr ( S_hat ) ) ) #NEWLINE# sq_S = ( sq_HS + ( ( 1.0 - H_hat ) * var_s0_hat ) ) #NEWLINE# presign = T . dot ( H_hat , self . bias_hid ) #NEWLINE# presign . name = 'presign' #NEWLINE# h_term = ( - presign ) #NEWLINE# assert ( len ( h_term . type . broadcastable ) == 1 ) #NEWLINE# precoeff = T . dot ( sq_S , self . alpha ) #NEWLINE# precoeff . name = 'precoeff' #NEWLINE# s_term_1 = ( half * precoeff ) #NEWLINE# assert ( len ( s_term_1 . type . broadcastable ) == 1 ) #NEWLINE# presign2 = T . dot ( HS , ( self . alpha * self . mu ) ) #NEWLINE# presign2 . name = 'presign2' #NEWLINE# s_term_2 = ( - presign2 ) #NEWLINE# assert ( len ( s_term_2 . type . broadcastable ) == 1 ) #NEWLINE# s_term_3 = ( half * T . dot ( H_hat , ( T . sqr ( self . mu ) * self . alpha ) ) ) #NEWLINE# assert ( len ( s_term_3 . type . broadcastable ) == 1 ) #NEWLINE# s_term = ( ( s_term_1 + s_term_2 ) + s_term_3 ) #NEWLINE# v_term_1 = ( half * T . dot ( T . sqr ( V ) , self . B ) ) #NEWLINE# assert ( len ( v_term_1 . type . broadcastable ) == 1 ) #NEWLINE# term6_factor1 = ( V * self . B ) #NEWLINE# term6_factor2 = T . dot ( HS , self . W . T ) #NEWLINE# v_term_2 = ( - ( term6_factor1 * term6_factor2 ) . sum ( axis = 1 ) ) #NEWLINE# assert ( len ( v_term_2 . type . broadcastable ) == 1 ) #NEWLINE# term7_subterm1 = T . dot ( T . sqr ( T . dot ( HS , self . W . T ) ) , self . B ) #NEWLINE# assert ( len ( term7_subterm1 . type . broadcastable ) == 1 ) #NEWLINE# term7_subterm2 = ( - T . dot ( T . dot ( T . sqr ( HS ) , T . sqr ( self . W . T ) ) , self . B ) ) #NEWLINE# term7_subterm3 = T . dot ( T . dot ( sq_HS , T . sqr ( self . W . T ) ) , self . B ) #NEWLINE# v_term_3 = ( half * ( ( term7_subterm1 + term7_subterm2 ) + term7_subterm3 ) ) #NEWLINE# assert ( len ( v_term_3 . type . broadcastable ) == 1 ) #NEWLINE# v_term = ( ( v_term_1 + v_term_2 ) + v_term_3 ) #NEWLINE# rval = ( ( h_term + s_term ) + v_term ) #NEWLINE# return rval