#NEWLINE# def grad( self , x ) : #NEWLINE# #INDENT# self . gradcalls += 1 #NEWLINE# log_pdot = np . dot ( self . F , x ) #NEWLINE# logZ = np . log ( sum ( np . exp ( log_pdot ) ) ) #NEWLINE# p = np . exp ( ( log_pdot - logZ ) ) #NEWLINE# return ( np . dot ( self . F . transpose ( ) , p ) - self . K )