#NEWLINE# def infer_S_hat( self , V , H_hat , S_hat ) : #NEWLINE# #INDENT# '\n        .. todo::\n\n            WRITEME\n        ' #NEWLINE# for ( Vv , Hv ) in get_debug_values ( V , H_hat ) : #NEWLINE# #INDENT# if ( Vv . shape != ( self . model . _test_batch_size , self . model . nvis ) ) : #NEWLINE# #INDENT# raise Exception ( ( ( ( ( 'Well this is awkward. We require visible input test tags to be of shape ' + str ( ( self . model . _test_batch_size , self . model . nvis ) ) ) + ' but the monitor gave us something of shape ' ) + str ( Vv . shape ) ) + ". The batch index part is probably only important if recycle_q is enabled. It's also probably not all that realistic to plan on telling the monitor what size of batch we need for test tags. the best thing to do is probably change self.model._test_batch_size to match what the monitor does" ) ) #NEWLINE# #UNINDENT# assert ( Vv . shape [ 0 ] == Hv . shape [ 0 ] ) #NEWLINE# if ( not ( Hv . shape [ 1 ] == self . model . nhid ) ) : #NEWLINE# #INDENT# raise AssertionError ( ( 'Hv.shape[1] is %d, does not match self.model.nhid, %d' % ( Hv . shape [ 1 ] , self . model . nhid ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# mu = self . model . mu #NEWLINE# alpha = self . model . alpha #NEWLINE# W = self . model . W #NEWLINE# B = self . model . B #NEWLINE# w = self . model . w #NEWLINE# BW = ( B . dimshuffle ( 0 , 'x' ) * W ) #NEWLINE# BW . name = 'infer_S_hat:BW' #NEWLINE# HS = ( H_hat * S_hat ) #NEWLINE# HS . name = 'infer_S_hat:HS' #NEWLINE# mean_term = ( mu * alpha ) #NEWLINE# mean_term . name = 'infer_S_hat:mean_term' #NEWLINE# assert ( V . dtype == config . floatX ) #NEWLINE# assert ( BW . dtype == config . floatX ) , ( 'Expected %s, got %s' % ( config . floatX , BW . dtype ) ) #NEWLINE# data_term = T . dot ( V , BW ) #NEWLINE# data_term . name = 'infer_S_hat:data_term' #NEWLINE# iterm_part_1 = ( - T . dot ( T . dot ( HS , W . T ) , BW ) ) #NEWLINE# iterm_part_1 . name = 'infer_S_hat:iterm_part_1' #NEWLINE# assert ( w . name is not None ) #NEWLINE# iterm_part_2 = ( w * HS ) #NEWLINE# iterm_part_2 . name = 'infer_S_hat:iterm_part_2' #NEWLINE# interaction_term = ( iterm_part_1 + iterm_part_2 ) #NEWLINE# interaction_term . name = 'infer_S_hat:interaction_term' #NEWLINE# for ( i1v , Vv ) in get_debug_values ( iterm_part_1 , V ) : #NEWLINE# #INDENT# assert ( i1v . shape [ 0 ] == Vv . shape [ 0 ] ) #NEWLINE# #UNINDENT# assert ( mean_term . dtype == config . floatX ) #NEWLINE# assert ( data_term . dtype == config . floatX ) #NEWLINE# assert ( interaction_term . dtype == config . floatX ) #NEWLINE# debug_interm = ( mean_term + data_term ) #NEWLINE# debug_interm . name = 'infer_S_hat:debug_interm' #NEWLINE# numer = ( HS + interaction_term ) #NEWLINE# numer . name = 'infer_S_hat:numer' #NEWLINE# assert ( numer . dtype == config . floatX ) #NEWLINE# alpha = self . model . alpha #NEWLINE# w = self . model . w #NEWLINE# denom = ( alpha + w ) #NEWLINE# assert ( denom . dtype == config . floatX ) #NEWLINE# denom . name = 'infer_S_hat:denom' #NEWLINE# S_hat = ( numer / denom ) #NEWLINE# return S_hat