繁体   English   中英

如何使用theano.gradient.hessian? 需要的例子

[英]How to use theano.gradient.hessian? Example needed

我尝试了下面的代码:

x=T.dvector('x')
y=T.dvector('y')
input=[x,y]
s=T.sum(x**2+y**2)
f=theano.gradient.hessian(s,wrt=input)
h=function(input,f)

然后我用以下真实值运行它

x=[1,2]
y=[1,2]
h([x,y]

然后我遇到以下错误

TypeError: ('Bad input argument to theano function with name "<ipython-input-115-32fd257c46ad>:7"  at index 0(0-based)', 'Wrong number of dimensions: expected 1, got 2 with shape (2L, 2L).')

我是python的新手,正在探索Theano构建神经网络。

h是一个接受两个参数的函数。 您给它一个参数,它是一个包含两个元素的列表。

尝试将h([x,y])更改为h(x,y)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM