我有一个损失函数 y
这是多个 shared variables theta1
, theta2
的函数,...
然后, y
wrt theta
的梯度下降可以简单地写成
import theano.tensor as T
theta_list = [theta1, theta2, theta3, theta4]
grad_list = T.grad(y, theta_list)
for theta, gradient in zip(theta_list, grad_list):
theta = theta - learning_rate * gradient
但是我不想使用 theta
的列表表示 . 那是,
import theano.tensor as T
thetas = <Properly concatenate thetas>
gradient = T.grad(y, thetas)
thetas = thetas - learning_rate * gradient
有没有办法实现这个?
简单 thetas = T.concatenate(theta_list) 在计算梯度时引发 DisconnectedInputError .