本文整理汇总了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'):