lucfra / FAR-HO

Gradient based hyperparameter optimization & meta-learning package for TensorFlow
MIT License
186 stars 47 forks source link

'FAR-HO/tests/check forward.ipynb' is not working! #5

Closed habibrk closed 6 years ago

habibrk commented 6 years ago

When I run this notebook I get the following error:

First I am told that the param lambda is not even connected with the model, which doe not make any sense.

Then it fails at the assertion a t line 113 in file utils.py

Please help, and it would be really helpful, if you could also provide an example notebook with ForwardHG for MNIST (both) with and without online learning ...

Thanks in advance ... Habib

//----------------------------------------------------------------------------------------------------------

Hyperparameter <tf.Variable 'lambda_components/0:0' shape=() dtype=float32_ref> is detached from this optimization dynamics.


AssertionError Traceback (most recent call last)

in () ----> 1 ss, farho, cost, oo = _test(far.ForwardHG) 2 3 tf.global_variables_initializer().run() 4 5 # execution with gradient descent! (looks ol) in _test(method) 25 optim_oo = tf.train.AdamOptimizer(.01) 26 farho = far.HyperOptimizer(hypergradient=method()) ---> 27 farho.minimize(oo, optim_oo, cost, io_optim) 28 return ss, farho, cost, oo /volume1/scratch/r0605927/backMeUpPlz/lib/python2.7/site-packages/far_ho/hyper_parameters.pyc in minimize(self, outer_objective, outer_objective_optimizer, inner_objective, inner_objective_optimizer, hyper_list, var_list, init_dynamics_dict, global_step, aggregation_fn, process_fn) 132 """ 133 optim_dict = self.inner_problem(inner_objective, inner_objective_optimizer, var_list, init_dynamics_dict) --> 134 self.outer_problem(outer_objective, optim_dict, outer_objective_optimizer, hyper_list, global_step) 135 return self.finalize(aggregation_fn=aggregation_fn, process_fn=process_fn) 136 /volume1/scratch/r0605927/backMeUpPlz/lib/python2.7/site-packages/far_ho/hyper_parameters.pyc in outer_problem(self, outer_objective, optim_dict, outer_objective_optimizer, hyper_list, global_step) 117 :return: itself 118 """ --> 119 hyper_list = self._hypergradient.compute_gradients(outer_objective, optim_dict, hyper_list=hyper_list) 120 self._h_optim_dict[outer_objective_optimizer].update(hyper_list) 121 self._global_step = global_step /volume1/scratch/r0605927/backMeUpPlz/lib/python2.7/site-packages/far_ho/hyper_gradients.pyc in compute_gradients(self, outer_objective, optimizer_dict, hyper_list) 343 # d_E_T = dot(vectorize_all(d_oo_d_state), vectorize_all(zs)) 344 d_E_T = [dot(d_oo_d_s, z) for d_oo_d_s, z in zip(d_oo_d_state, zs) --> 345 if d_oo_d_s is not None and z is not None] 346 hg = maybe_add(tf.reduce_sum(d_E_T), d_oo_d_hyp) # this is right... the error is not here! 347 # hg = maybe_add(d_E_T, d_oo_d_hyp) /volume1/scratch/r0605927/backMeUpPlz/lib/python2.7/site-packages/far_ho/utils.pyc in dot(a, b, name) 111 Dot product between vectors `a` and `b` with optional name 112 """ --> 113 assert a.shape.ndims == 1, '{} must be a vector'.format(a) 114 assert b.shape.ndims == 1, '{} must be a vector'.format(b) 115 with tf.name_scope(name, 'Dot', [a, b]): AssertionError: Tensor("Mean_1_1/gradients/mul_5_grad/Reshape:0", shape=(2, 3), dtype=float32) must be a vector
lucfra commented 6 years ago

Hi habibrk,

Yes you're right. I've introduced a stupid bug with this commit https://github.com/lucfra/FAR-HO/commit/ae8c47df2aad346ea13b4f15b3410c94715e837b Now should work fine. Let me know!

For the examples you're right as well. As soon as I can I'll add some with ForwardHG and Real-Time HO... I'll keep the issue open.

habibrk commented 6 years ago

@lucfra it seems to work now, thanks again. Yes, having ForwardHG and RTHO for MNIST would be awesome, looking forward to them.

lucfra commented 6 years ago

Hi, after quite a long time, I've uploaded a notebook that contains a simple experiment with RTHO, that I've recently done for AutoML workshop at ICML 2018. Here it is!

If you're still interested and have any questions feel free to write!

Cheers,

Luca