Hi, I have a question about computing gradient. In general, I can use the theano.gradient.grad to compute the gradient for the whole graph given the cost. In my situation, I cannot compute the cost, but I know the gradient of the weights last layer. Can I still automatically compute the gradient of previous layers? My understanding is that I should still use the same function, but put the cost as None and give the ones I know as known_grads.
I tried a small example, where The original gradient is the following original_all_grad = T.grad(cost=loss_train, wrt=params) These are the parameters params = lasagne.layers.get_all_params(model, trainable=True) last_layer_params =model.get_params(trainable=True) other_param = params[0:-1] I computed the last layer gradient still using the same cost, although later this would change. known_grad = T.grad(loss_train, last_layer_params) Compute the gradient with respect to the known gradient. output = lasagne.layers.get_output(model) dic = OrderedDict([(output, known_grad[0])]) all_grad = T.grad(cost=None,wrt=other_param, known_grads=dic) The surprising result is that the all_grad and original_all_grad will not be identical values for other params. I am not sure what I did wrong here. I am really gratefully for any help. Vena -- --- You received this message because you are subscribed to the Google Groups "theano-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.