本文整理匯總了Python中NN.grad方法的典型用法代碼示例。如果您正苦於以下問題:Python NN.grad方法的具體用法?Python NN.grad怎麽用?Python NN.grad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NN
的用法示例。
在下文中一共展示了NN.grad方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: func
# 需要導入模塊: import NN [as 別名]
# 或者: from NN import grad [as 別名]
#...calc best one again
func(solution,maindir)
elif fmethod in ('sd_dynamics','SD_dynamics','SD'):
print '>>>>> SD_dynamics was selected.'
solution= sd_dynamics(func,vars,args=(maindir,)
,fprime=grad_linreg
,maxiter=niter)
elif fmethod in ('check_grad'):
print '>>>>> check_grad was selected.'
if gradient in ('numerical'):
print ' Done nothing, because gradient==numerical.'
else:
if potential == 'linreg':
grad= grad_linreg(vars,maindir)
elif potential == 'NN':
grad= NN.grad(vars,maindir,)
agrad= opt.approx_fprime(vars,func,eps,maindir)
print ''
print '>>>>> check_grad report:'
print ' diff =',np.sqrt(np.sum((grad-agrad)**2))
print ' grad aprrox_grad error (%)'
for i in range(len(grad)):
print ' {0:20.6f} {1:20.6f} {2:12.2f}'.format(grad[i],\
agrad[i],\
abs(grad[i]-agrad[i])/abs(grad[i])*100)
solution= vars
elif fmethod in ('test','TEST'):
print '>>>>> TEST was selected.'
#func(vars,maindir) # func is already evaluated before
if gradient != 'numerical':
if potential in ('linreg'):