kohpangwei / influence-release

MIT License
776 stars 175 forks source link

Crashes at keras.layers.Flatten for keras 2.0.6 #2

Closed chiachun closed 7 years ago

chiachun commented 7 years ago

tensorflow version: 1.3.0 run_rbf_comparison.py crashes at keras.layers.Flatten with keras 2.0.6. Fixed by switching to keras 2.0.0

Suggestion: Please state the required version of keras (and other packages). Perhaps this information is available somewhere but I haven't found.

run_rbf_comparison.py in () 172 train_dir='output', 173 log_dir='log', --> 174 model_name=full_model_name) 175 train_inception_features_val = generate_inception_features( 176 full_model,

influence/inceptionModel.py in init(self, img_side, num_channels, weight_decay, kwargs) 39 self.num_features = 2048 # Hardcoded for inception. For some reason Flatten() doesn't register num_features. 40 ---> 41 super(BinaryInceptionModel, self).init(kwargs) 42 43 self.load_inception_weights()

influence/genericNeuralNet.pyc in init(self, **kwargs) 121 self.logits = self.inference(self.input_placeholder, self.labels_placeholder) 122 else: --> 123 self.logits = self.inference(self.input_placeholder) 124 125 self.total_loss, self.loss_no_reg, self.indiv_loss_no_reg = self.loss(

influence/inceptionModel.py in inference(self, input) 168 pooled_inception_features = AveragePooling2D((8, 8), strides=(8, 8), name='avg_pool')(raw_inception_features) 169 print (pooled_inception_features) --> 170 self.inception_features = Flatten(name='flatten')(pooled_inception_features) 171 172

......./virtualenv_folder/tensorflow/local/lib/python2.7/site-packages/keras/engine/topology.pyc in call(self, inputs, **kwargs) 613 # Infering the output shape is only relevant for Theano. 614 if all([s is not None for s in _to_list(input_shape)]): --> 615 output_shape = self.compute_output_shape(input_shape) 616 else: 617 if isinstance(input_shape, list):

......./virtualenv_folder/tensorflow/local/lib/python2.7/site-packages/keras/layers/core.pyc in compute_output_shape(self, input_shape) 475 raise ValueError('The shape of the input to "Flatten" ' 476 'is not fully defined ' --> 477 '(got ' + str(input_shape[1:]) + '. ' 478 'Make sure to pass a complete "input_shape" ' 479 'or "batch_input_shape" argument to the first '

ValueError: The shape of the input to "Flatten" is not fully defined (got (None, None, 2048). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.

kohpangwei commented 7 years ago

Thanks for finding this! The version information was implicitly in our Dockerfile (https://hub.docker.com/r/pangwei/tf1.1/) but you're right that I should make it explicit. I'm not sure why the newer version of Keras fails; let me know if you know how to fix it!