我有一个损失函数y
,它是多个共享变量的函数 theta1
,theta2
,...
然后,y
wrt theta
s的梯度下降可以简单地写为
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 。