如何在theano中计算梯度wrt连接变量

时间:2016-12-15 06:06:45

标签: gradient theano

我有一个损失函数y,它是多个共享变量的函数 theta1theta2,...

然后,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

0 个答案:

没有答案
相关问题