#NEWLINE# @ Cache_this ( limit = 3 , ignore_args = ( 0 , 2 , 3 , 4 ) ) #NEWLINE# def _psiDerivativecomputations( self , kern , dL_dpsi0 , dL_dpsi1 , dL_dpsi2 , Z , variational_posterior ) : #NEWLINE# #INDENT# if ( len ( dL_dpsi2 . shape ) == 2 ) : #NEWLINE# #INDENT# dL_dpsi2 = ( ( dL_dpsi2 + dL_dpsi2 . T ) / 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dL_dpsi2 = ( ( dL_dpsi2 + np . swapaxes ( dL_dpsi2 , 1 , 2 ) ) / 2 ) #NEWLINE# #UNINDENT# ( variance , lengthscale ) = ( kern . variance , kern . lengthscale ) #NEWLINE# from .... util.linalg_gpu import sum_axis #NEWLINE# ARD = ( len ( lengthscale ) != 1 ) #NEWLINE# ( N , M , Q ) = self . get_dimensions ( Z , variational_posterior ) #NEWLINE# psi1_gpu = self . gpuCache [ 'psi1_gpu' ] #NEWLINE# psi2n_gpu = self . gpuCache [ 'psi2n_gpu' ] #NEWLINE# l_gpu = self . gpuCache [ 'l_gpu' ] #NEWLINE# Z_gpu = self . gpuCache [ 'Z_gpu' ] #NEWLINE# mu_gpu = self . gpuCache [ 'mu_gpu' ] #NEWLINE# S_gpu = self . gpuCache [ 'S_gpu' ] #NEWLINE# dvar_gpu = self . gpuCache [ 'dvar_gpu' ] #NEWLINE# dl_gpu = self . gpuCache [ 'dl_gpu' ] #NEWLINE# dZ_gpu = self . gpuCache [ 'dZ_gpu' ] #NEWLINE# dmu_gpu = self . gpuCache [ 'dmu_gpu' ] #NEWLINE# dS_gpu = self . gpuCache [ 'dS_gpu' ] #NEWLINE# grad_l_gpu = self . gpuCache [ 'grad_l_gpu' ] #NEWLINE# grad_mu_gpu = self . gpuCache [ 'grad_mu_gpu' ] #NEWLINE# grad_S_gpu = self . gpuCache [ 'grad_S_gpu' ] #NEWLINE# if self . GPU_direct : #NEWLINE# #INDENT# dL_dpsi1_gpu = dL_dpsi1 #NEWLINE# dL_dpsi2_gpu = dL_dpsi2 #NEWLINE# dL_dpsi0_sum = dL_dpsi0 . get ( ) . sum ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dL_dpsi1_gpu = self . gpuCache [ 'dL_dpsi1_gpu' ] #NEWLINE# dL_dpsi2_gpu = self . gpuCache [ 'dL_dpsi2_gpu' ] #NEWLINE# dL_dpsi1_gpu . set ( np . asfortranarray ( dL_dpsi1 ) ) #NEWLINE# dL_dpsi2_gpu . set ( np . asfortranarray ( dL_dpsi2 ) ) #NEWLINE# dL_dpsi0_sum = dL_dpsi0 . sum ( ) #NEWLINE# #UNINDENT# self . reset_derivative ( ) #NEWLINE# self . g_psi1compDer . prepared_call ( ( self . blocknum , 1 ) , ( self . threadnum , 1 , 1 ) , dvar_gpu . gpudata , dl_gpu . gpudata , dZ_gpu . gpudata , dmu_gpu . gpudata , dS_gpu . gpudata , dL_dpsi1_gpu . gpudata , psi1_gpu . gpudata , np . float64 ( variance ) , l_gpu . gpudata , Z_gpu . gpudata , mu_gpu . gpudata , S_gpu . gpudata , np . int32 ( N ) , np . int32 ( M ) , np . int32 ( Q ) ) #NEWLINE# self . g_psi2compDer . prepared_call ( ( self . blocknum , 1 ) , ( self . threadnum , 1 , 1 ) , dvar_gpu . gpudata , dl_gpu . gpudata , dZ_gpu . gpudata , dmu_gpu . gpudata , dS_gpu . gpudata , dL_dpsi2_gpu . gpudata , psi2n_gpu . gpudata , np . float64 ( variance ) , l_gpu . gpudata , Z_gpu . gpudata , mu_gpu . gpudata , S_gpu . gpudata , np . int32 ( N ) , np . int32 ( M ) , np . int32 ( Q ) ) #NEWLINE# dL_dvar = ( dL_dpsi0_sum + dvar_gpu . get ( ) . sum ( ) ) #NEWLINE# sum_axis ( grad_mu_gpu , dmu_gpu , ( N * Q ) , dL_dpsi2_gpu . blocknum ) #NEWLINE# dL_dmu = grad_mu_gpu . get ( ) #NEWLINE# sum_axis ( grad_S_gpu , dS_gpu , ( N * Q ) , self . blocknum ) #NEWLINE# dL_dS = grad_S_gpu . get ( ) #NEWLINE# dL_dZ = dZ_gpu . get ( ) #NEWLINE# if ARD : #NEWLINE# #INDENT# sum_axis ( grad_l_gpu , dl_gpu , Q , self . blocknum ) #NEWLINE# dL_dlengscale = grad_l_gpu . get ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dL_dlengscale = dl_gpu . get ( ) . sum ( ) #NEWLINE# #UNINDENT# return ( dL_dvar , dL_dlengscale , dL_dZ , dL_dmu , dL_dS )