#NEWLINE# def update_gradients_full( self , dL_dK , X , X2 = None ) : #NEWLINE# #INDENT# if hasattr ( X , 'values' ) : #NEWLINE# #INDENT# X = X . values #NEWLINE# #UNINDENT# self . B . gradient = np . zeros ( self . B . shape ) #NEWLINE# self . C . gradient = np . zeros ( self . C . shape ) #NEWLINE# self . W . gradient = np . zeros ( self . W . shape ) #NEWLINE# self . lengthscale . gradient = np . zeros ( self . lengthscale . shape ) #NEWLINE# index = np . int_ ( X [ : , 1 ] ) #NEWLINE# index = index . reshape ( index . size ) #NEWLINE# X_flag = ( index [ 0 ] >= self . output_dim ) #NEWLINE# if ( X2 is None ) : #NEWLINE# #INDENT# if X_flag : #NEWLINE# #INDENT# index -= self . output_dim #NEWLINE# tmp = ( dL_dK * self . _gkuu_lq ( X , index ) ) #NEWLINE# for q in np . unique ( index ) : #NEWLINE# #INDENT# ind = np . where ( ( index == q ) ) #NEWLINE# self . lengthscale . gradient [ q ] = tmp [ np . ix_ ( ind [ 0 ] , ind [ 0 ] ) ] . sum ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( X2 , 'values' ) : #NEWLINE# #INDENT# X2 = X2 . values #NEWLINE# #UNINDENT# index2 = np . int_ ( X2 [ : , 1 ] ) #NEWLINE# index2 = index2 . reshape ( index2 . size ) #NEWLINE# X2_flag = ( index2 [ 0 ] >= self . output_dim ) #NEWLINE# if ( ( not X_flag ) and X2_flag ) : #NEWLINE# #INDENT# index2 -= self . output_dim #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dL_dK = dL_dK . T #NEWLINE# indtemp = ( index - self . output_dim ) #NEWLINE# Xtemp = X #NEWLINE# X = X2 #NEWLINE# X2 = Xtemp #NEWLINE# index = index2 #NEWLINE# index2 = indtemp #NEWLINE# #UNINDENT# ( glq , gSdq , gB , gC ) = self . _gkfu ( X , index , X2 , index2 ) #NEWLINE# tmp = ( dL_dK * glq ) #NEWLINE# for q in np . unique ( index2 ) : #NEWLINE# #INDENT# ind = np . where ( ( index2 == q ) ) #NEWLINE# self . lengthscale . gradient [ q ] = tmp [ : , ind ] . sum ( ) #NEWLINE# #UNINDENT# tmpB = ( dL_dK * gB ) #NEWLINE# tmpC = ( dL_dK * gC ) #NEWLINE# tmp = ( dL_dK * gSdq ) #NEWLINE# for d in np . unique ( index ) : #NEWLINE# #INDENT# ind = np . where ( ( index == d ) ) #NEWLINE# self . B . gradient [ d ] = tmpB [ ind , : ] . sum ( ) #NEWLINE# self . C . gradient [ d ] = tmpC [ ind , : ] . sum ( ) #NEWLINE# for q in np . unique ( index2 ) : #NEWLINE# #INDENT# ind2 = np . where ( ( index2 == q ) ) #NEWLINE# self . W . gradient [ ( d , q ) ] = tmp [ np . ix_ ( ind [ 0 ] , ind2 [ 0 ] ) ] . sum ( )