YerevaNN / R-NET-in-Keras

Open R-NET (hy` առնետ 🐁) implementation and detailed analysis: https://git.io/vd8dx
http://yerevann.github.io/2017/08/25/challenges-of-reproducing-r-net-neural-network-using-keras/
MIT License
178 stars 88 forks source link

ValueError: Layer question_attn_gru_1 expects 2 inputs, but it received 7 input tensors #13

Open anand-ar opened 7 years ago

anand-ar commented 7 years ago

Hi,

I used your trained model and ran predict script - I get the the above errror

ValueError: Layer question_attn_gru_1 expects 2 inputs, but it received 7 input tensors. Input received: [<tf.Tensor 'uP/cond/Merge:0' shape=(?, ?, 90) dtype=float32>, <tf.Tensor 'uQ/cond/Merge:0' shape=(?, ?, 90) dtype=float32>, <tf.Tensor 'mul:0' shape=(90, 45) dtype=float32>, <tf.Tensor 'mul_1:0' shape=(45, 45) dtype=float32>, <tf.Tensor 'mul_2:0' shape=(90, 45) dtype=float32>, <tf.Tensor 'mul_3:0' shape=(45, 1) dtype=float32>, <tf.Tensor 'mul_4:0' shape=(180, 180) dtype=float32>]

what needs to be done

Thanks

mahnerak commented 7 years ago

We have a problem with Keras > 2.0.8. Consider using Keras 2.0.6 untill we fix the bug.

anand-ar commented 7 years ago

switching to 2.06 avoided that issue - now this error has come up Using TensorFlow backend. Preparing model...Traceback (most recent call last): File "predict.py", line 33, in model = load_model(args.model, custom_objects()) File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/models.py", line 233, in load_model File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/models.py", line 307, in model_from_config File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/layers/init.py", line 54, in deserialize File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/utils/generic_utils.py", line 139, in deserialize_keras_object File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.py", line 2450, in from_config File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.py", line 2447, in process_layer File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.py", line 571, in call File "/Users/arunachalam/rnet/R-NET-in-Keras/layers/QuestionPooling.py", line 26, in build assert(isinstance(input_shape, list) and len(input_shape) == 5)

still using your model

Thanks

MartinXPN commented 7 years ago

That error occurred because QuestionPooling layer was updated in later commits to be consistent with R-Net paper. However the provided model was built with previous implementation. To avoid this error and use the model without errors run the following command git checkout 715221945416f312c253d88bf9ca2c1debef61d3 and then run the prediction script

anand-ar commented 7 years ago

Ok, prediction script worked with patch on the complete dataset

Then I wanted to just check one topic - super_bowl_50 - cut the input to just have super_bowl_50 passage and questions - parsed and preprocessed - looks like some keras compatibility issue or your implementation requires complete data set

prediction script had this error

Preparing model...Done! Loading data...Done! Running predicting model...Traceback (most recent call last): File "predict.py", line 54, in verbose=1) File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/legacy/interfaces.py", line 87, in wrapper File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/training.py", line 2085, in predict_generator File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/training.py", line 1622, in predict_on_batch File "/Users/arunachalam/anaconda/lib/python2.7/site-packages/Keras-2.0.6-py2.7.egg/keras/engine/training.py", line 78, in _standardize_input_data ValueError: Error when checking model : the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 4 arrays but instead got the following list of 2 arrays: [array([[[-0.41758001, -0.16617 , -0.19927999, ..., -0.155 , 0.50695002, 0.068692 ], [-0.26901001, 0.63352001, 0.36471999, ..., 0.43628001, 0.53119999, -0.303649...

MartinXPN commented 7 years ago

Have you included char-level-embeddings while parsing? As far as I understand the model that you are trying to run requires them (vectors + embeddings => 4 arrays)

shwetgarg commented 6 years ago

I used your trained model and ran predict script after following 2 steps:

  1. installed Keras 2.0.6
  2. git checkout 715221945416f312c253d88bf9ca2c1debef61d3

But I am getting following error:

File "predict.py", line 54, in verbose=1) File "/dev/shm/shweta/software/anaconda2/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 87, in wrapper return func(*args, **kwargs) File "/dev/shm/shweta/software/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 2085, in predict_generator outs = self.predict_on_batch(x) File "/dev/shm/shweta/software/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 1622, in predict_on_batch self._feed_input_shapes) File "/dev/shm/shweta/software/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 140, in _standardize_input_data str(array.shape)) ValueError: Error when checking : expected Q_vecs to have shape (None, None, 300) but got array with shape (100, 30, 25)

What needs to be done.

Thanks

TarunTater commented 6 years ago

@shwetgarg - had the same set of errors. Were you able to solve the last error? Thanks

soni-sarvesh commented 6 years ago

@shwetgarg I am also getting the same error. Could you resolve the issue?

blurLake commented 4 years ago

I have similar error with Keras 2.3.1.

edmondja commented 4 years ago

I have similar error with Keras 2.3.1.

+1

sarahosini commented 3 years ago

Hi I ran a code for my dataset that I was able to learn several times. Now I want to learn it again. It gives the following error if I have not changed the code.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:805 train_function * return step_function(self, iterator) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:795 step_function * outputs = model.distribute_strategy.run(run_step, args=(data,)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica return self._call_for_each_replica(fn, args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica return fn(args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:788 run_step outputs = model.train_step(data) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:754 train_step y_pred = self(x, training=True) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 call input_spec.assert_input_compatibility(self.input_spec, inputs, self.name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/input_spec.py:207 assert_input_compatibility ' input tensors. Inputs received: ' + str(inputs))

ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None) dtype=float32>]

Can you guide me?

JosephTeja commented 3 years ago

Hi I ran a code for my dataset that I was able to learn several times. Now I want to learn it again. It gives the following error if I have not changed the code.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:805 train_function * return step_function(self, iterator) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:795 step_function * outputs = model.distribute_strategy.run(run_step, args=(data,)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica return self._call_for_each_replica(fn, args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica return fn(args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:788 run_step outputs = model.train_step(data) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:754 train_step y_pred = self(x, training=True) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 call input_spec.assert_input_compatibility(self.input_spec, inputs, self.name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/input_spec.py:207 assert_input_compatibility ' input tensors. Inputs received: ' + str(inputs))

ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None) dtype=float32>]

Can you guide me?

@sarahosini i'm havinf the same problem. did you get it resolved?

itskarthicklakshmanan commented 3 years ago

Hi I ran a code for my dataset that I was able to learn several times. Now I want to learn it again. It gives the following error if I have not changed the code.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:805 train_function * return step_function(self, iterator) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:795 step_function * outputs = model.distribute_strategy.run(run_step, args=(data,)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica return self._call_for_each_replica(fn, args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica return fn(args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:788 run_step outputs = model.train_step(data) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:754 train_step y_pred = self(x, training=True) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 call input_spec.assert_input_compatibility(self.input_spec, inputs, self.name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/input_spec.py:207 assert_input_compatibility ' input tensors. Inputs received: ' + str(inputs))

ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None) dtype=float32>]

Can you guide me?

@sarahosini, I am facing the same issue! any solution found for this error!

smitshah commented 3 years ago

Hi I ran a code for my dataset that I was able to learn several times. Now I want to learn it again. It gives the following error if I have not changed the code. /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:805 train_function * return step_function(self, iterator) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:795 step_function * outputs = model.distribute_strategy.run(run_step, args=(data,)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica return self._call_for_each_replica(fn, args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica return fn(args, kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:788 run_step outputs = model.train_step(data) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:754 train_step y_pred = self(x, training=True) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 call input_spec.assert_input_compatibility(self.input_spec, inputs, self.name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/input_spec.py:207 assert_input_compatibility ' input tensors. Inputs received: ' + str(inputs))

ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None) dtype=float32>]

Can you guide me?

@sarahosini, I am facing the same issue! any solution found for this error!

@sarahosini, I am also getting the same error. Has any solution been found for this!