pierluigiferrari / ssd_keras

A Keras port of Single Shot MultiBox Detector
Apache License 2.0
1.86k stars 938 forks source link

Error: InvalidArgumentError: All dimensions except 2 must match... (on concatenating) #355

Closed babak-abad closed 4 years ago

babak-abad commented 4 years ago

I'm programming in python 3.7 via pycharm pro. When I try to train using ssd7_training, I get errors listed below:

Epoch 1/20
Traceback (most recent call last):
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\engine\training_generator.py", line 215, in fit_generator
    class_weight=class_weight)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\engine\training.py", line 1449, in train_on_batch
    outputs = self.train_function(ins)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 2979, in __call__
    return self._call(inputs)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 2937, in _call
    fetched = self._callable_fn(*array_vals)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\tensorflow_core\python\client\session.py", line 1472, in __call__
    run_metadata_ptr)
tensorflow.python.framework.errors_impl.InvalidArgumentError: All dimensions except 2 must match. Input 2 has shape [16 28800 8] and doesn't match input 0 with shape [16 191040 2].
     [[{{node training/Adam/gradients/predictions/concat_grad/ConcatOffset}}]]

Process finished with exit code -1

Enviroment:

width/height of image: 1920/1200 channels = 3 number of classes = 2/1 (I tested both of them)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

PaulZhangIsing commented 3 years ago

Please go to keras_layers/anchor boxes scripts and change the K.image_dim_ordering() == 'tf':(line 171 and line 258 ) to K.image_data_format() == 'channels_last':

I'm programming in python 3.7 via pycharm pro. When I try to train using ssd7_training, I get errors listed below:

Epoch 1/20
Traceback (most recent call last):
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\engine\training_generator.py", line 215, in fit_generator
    class_weight=class_weight)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\engine\training.py", line 1449, in train_on_batch
    outputs = self.train_function(ins)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 2979, in __call__
    return self._call(inputs)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 2937, in _call
    fetched = self._callable_fn(*array_vals)
  File "E:\Projects\ssd_keras-master\venv\lib\site-packages\tensorflow_core\python\client\session.py", line 1472, in __call__
    run_metadata_ptr)
tensorflow.python.framework.errors_impl.InvalidArgumentError: All dimensions except 2 must match. Input 2 has shape [16 28800 8] and doesn't match input 0 with shape [16 191040 2].
   [[{{node training/Adam/gradients/predictions/concat_grad/ConcatOffset}}]]

Process finished with exit code -1

Enviroment:

* win 10

* Keras                  2.2.5

* tensorflow             1.15.3/ 1.15.2 (I tested both of them)

width/height of image: 1920/1200 channels = 3 number of classes = 2/1 (I tested both of them)