Hi Tanjed, I wonder if you have already solved this issue. Actually, I'm trying to use the exact hessian as well, to see the difference performance.
Would you please tell me if you have any issues when run you hessian_vector_product function. Since I encountered the following error when I run the same function. *TypeError: can't multiply sequence by non-int of type 'list'* *Best,* *Xi* On Tuesday, February 16, 2016 at 9:24:00 PM UTC-5, tanjeb wrote: > > Hi, > > I have been trying to modify Mr. Nicolas Boulanger-Lewandowski's > implementation of the HF algorithm ( https://github.com/boulanni/theano-hf ) > to > use the exact hessian instead of the Gauss-Newton matrix. I am trying to > replace the "gauss_newton_product" method with the following method: > > > def hessian_vector_product(cost, p, v): > > gc = T.grad(cost, p) > > Hv = T.grad(T.sum(gc * v), p) > > return Hv > > > However, when I execute the code, the following expression results in > an error: > > self.function_Hv = theano.function(inputs + v + [coefficient], Hv, > givens=givens, on_unused_input='ignore') > > > Traceback (most recent call last): > File "<string>", line 1, in <module> > File "hf_test_ex.py", line 110, in example_NN > hf_optimizer(p, inputs, costs).train(gradient_dataset, cg_dataset, > initial_lambda=1.0, preconditioner=True, validation=valid_dataset) > File "hf_test.py", line 69, in __init__ > self.function_Hv = theano.function(inputs + v + [coefficient], Hv, > givens=givens, on_unused_input='ignore') > File > "/usr/local/lib/python2.7/dist-packages/theano/compile/function.py", line > 273, in function > raise Exception("Input variables of a Theano function should be " > Exception: Input variables of a Theano function should be contained in a > list, even when there is a single input. > > > But, this very same expression works if "gauss_newton_product" method is > used. > > I used the same xor data-set provided by Mr. Lewandowski. I suppose the > error has something to do with the dimension of "v", as for my case I > defined "v" as a flat vector. > > Can anybody please explain this line from Mr. Lewandowski's implementation: > > self.function_Gv = theano.function(inputs + v + [coefficient], Gv, > givens=givens, > on_unused_input='ignore') > > Why his implementation doesn't result in an error even if the input to the > function is not contained in a list? > In particular, why the input is not like this: [ inputs, v, coefficient ]? > > Any help would be highly appreciated. > > Thanks, > Tanjed Mohammed Tawhid > > -- --- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
