maxpumperla / hyperas

Keras + Hyperopt: A very simple wrapper for convenient hyperparameter optimization
http://maxpumperla.com/hyperas/
MIT License
2.17k stars 316 forks source link

Keras throws assertion error after hundreds of rounds #209

Open jeremywang123 opened 5 years ago

jeremywang123 commented 5 years ago

Hi,

I am trying to use Hyperas for tuning and have this error. I posted this in Hyperopt as well since I am not sure what caused this issue. I have tried Keras 2.2.4, 2.2.2, 2.1.6, none of them solved this. I am also using latest code of both Hyperopt & Hyperas

Shortly, after hundreds of rounds (usually around 200 rounds), Keras throws this error from this part of code: def compute_output_shape(self, input_shape): assert input_shape and len(input_shape) >= 2 assert input_shape[-1] output_shape = list(input_shape) output_shape[-1] = self.units return tuple(output_shape)

The full log looks like this: Traceback (most recent call last): File "/home/xxx/PycharmProjects/xxx/aaa/bbb.py", line 480, in
File "/home/xxx/PycharmProjects/xxx/aaa/bbb.py", line 476, in train_pipe
File "/home/xxx/PycharmProjects/xxx/aaa/bbb.py", line 186, in hyper_opt """ File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperas/optim.py", line 67, in minimize verbose=verbose) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperas/optim.py", line 133, in base_minimizer return_argmin=True), File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/fmin.py", line 367, in fmin return_argmin=return_argmin, File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/base.py", line 635, in fmin return_argmin=return_argmin) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/fmin.py", line 385, in fmin rval.exhaust() File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/fmin.py", line 244, in exhaust self.run(self.max_evals - n_done, block_until_done=self.asynchronous) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/fmin.py", line 218, in run self.serial_evaluate() File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/fmin.py", line 137, in serial_evaluate result = self.domain.evaluate(spec, ctrl) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/hyperopt/base.py", line 840, in evaluate rval = self.fn(pyll_rval) File "/home/xxx.w/PycharmProjects/syntactic_parser_based_classifier/Anaphora/temp_model.py", line 165, in keras_fmin_fnct

File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/keras/engine/sequential.py", line 185, in add output_tensor = layer(self.outputs[0]) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/keras/engine/base_layer.py", line 474, in call output_shape = self.compute_output_shape(input_shape) File "/home/xxx.w/anaconda2/lib/python2.7/site-packages/keras/layers/core.py", line 883, in compute_output_shape assert input_shape[-1] AssertionError

Any help is appreciated! Thank you.

maxpumperla commented 5 years ago

@jeremywang123 see here as well https://github.com/hyperopt/hyperopt/issues/443#issuecomment-443528540