[英]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.