pierluigiferrari / ssd_keras

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

Error running the fit_generator method #353

Closed Sri-user closed 4 years ago

Sri-user commented 4 years ago

Beautiful implementation of SSD. Thank you very much for that

I was trying to run the fit_generator in sdd300_training. I had resized all my images to 300,300

I get the below error

"Input to reshape is a tensor with 622592 values, but the requested shape requires a multiple of 46208 [[{{node conv4_3_norm_mbox_priorbox_reshape/Reshape}}]]"

I am using Tensorfow 1.14.0 and keras 2.0.4

Here is the complete error trace

""" InvalidArgumentError Traceback (most recent call last) ~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, args) 1355 try: -> 1356 return fn(args) 1357 except errors.OpError as e:

~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata) 1340 return self._call_tf_sessionrun( -> 1341 options, feed_dict, fetch_list, target_list, run_metadata) 1342

~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata) 1428 self._session, options, feed_dict, fetch_list, target_list, -> 1429 run_metadata) 1430

InvalidArgumentError: Input to reshape is a tensor with 622592 values, but the requested shape requires a multiple of 46208 [[{{node conv4_3_norm_mbox_priorbox_reshape/Reshape}}]]

During handling of the above exception, another exception occurred:

InvalidArgumentError Traceback (most recent call last)

in 10 validation_data=val_generator, 11 validation_steps=ceil(val_dataset_size/batch_size), ---> 12 verbose=1) ~\anaconda3\lib\site-packages\keras\legacy\interfaces.py in wrapper(*args, **kwargs) 86 warnings.warn('Update your `' + object_name + 87 '` call to the Keras 2 API: ' + signature, stacklevel=2) ---> 88 return func(*args, **kwargs) 89 wrapper._legacy_support_signature = inspect.getargspec(func) 90 return wrapper ~\anaconda3\lib\site-packages\keras\engine\training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_q_size, workers, pickle_safe, initial_epoch) 1888 outs = self.train_on_batch(x, y, 1889 sample_weight=sample_weight, -> 1890 class_weight=class_weight) 1891 1892 if not isinstance(outs, list): ~\anaconda3\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight) 1631 ins = x + y + sample_weights 1632 self._make_train_function() -> 1633 outputs = self.train_function(ins) 1634 if len(outputs) == 1: 1635 return outputs[0] ~\anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in __call__(self, inputs) 2227 session = get_session() 2228 updated = session.run(self.outputs + [self.updates_op], -> 2229 feed_dict=feed_dict) 2230 return updated[:len(self.outputs)] 2231 ~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 948 try: 949 result = self._run(None, fetches, feed_dict, options_ptr, --> 950 run_metadata_ptr) 951 if run_metadata: 952 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) ~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1171 if final_fetches or final_targets or (handle and feed_dict_tensor): 1172 results = self._do_run(handle, final_targets, final_fetches, -> 1173 feed_dict_tensor, options, run_metadata) 1174 else: 1175 results = [] ~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1348 if handle is None: 1349 return self._do_call(_run_fn, feeds, fetches, targets, options, -> 1350 run_metadata) 1351 else: 1352 return self._do_call(_prun_fn, handle, feeds, fetches) ~\anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args) 1368 pass 1369 message = error_interpolation.interpolate(message, self._graph) -> 1370 raise type(e)(node_def, op, message) 1371 1372 def _extend_graph(self): InvalidArgumentError: Input to reshape is a tensor with 622592 values, but the requested shape requires a multiple of 46208 [[node conv4_3_norm_mbox_priorbox_reshape/Reshape (defined at C:\Users\srith\anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py:1694) ]] Errors may have originated from an input operation. Input Source operations connected to node conv4_3_norm_mbox_priorbox_reshape/Reshape: conv4_3_norm_mbox_priorbox/Tile (defined at C:\Users\srith\anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py:1872) Original stack trace for 'conv4_3_norm_mbox_priorbox_reshape/Reshape': File "C:\Users\srith\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\srith\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel_launcher.py", line 16, in app.launch_new_instance() File "C:\Users\srith\anaconda3\lib\site-packages\traitlets\config\application.py", line 664, in launch_instance app.start() File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 583, in start self.io_loop.start() File "C:\Users\srith\anaconda3\lib\site-packages\tornado\platform\asyncio.py", line 153, in start self.asyncio_loop.run_forever() File "C:\Users\srith\anaconda3\lib\asyncio\base_events.py", line 538, in run_forever self._run_once() File "C:\Users\srith\anaconda3\lib\asyncio\base_events.py", line 1782, in _run_once handle._run() File "C:\Users\srith\anaconda3\lib\asyncio\events.py", line 88, in _run self._context.run(self._callback, *self._args) File "C:\Users\srith\anaconda3\lib\site-packages\tornado\ioloop.py", line 690, in lambda f: self._run_callback(functools.partial(callback, future)) File "C:\Users\srith\anaconda3\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback ret = callback() File "C:\Users\srith\anaconda3\lib\site-packages\tornado\gen.py", line 787, in inner self.run() File "C:\Users\srith\anaconda3\lib\site-packages\tornado\gen.py", line 748, in run yielded = self.gen.send(value) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 361, in process_one yield gen.maybe_future(dispatch(*args)) File "C:\Users\srith\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper yielded = next(result) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 268, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "C:\Users\srith\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper yielded = next(result) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 541, in execute_request user_expressions, allow_stdin, File "C:\Users\srith\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper yielded = next(result) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 300, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "C:\Users\srith\anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 536, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2858, in run_cell raw_cell, store_history, silent, shell_futures) File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2886, in _run_cell return runner(coro) File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\async_helpers.py", line 68, in _pseudo_sync_runner coro.send(None) File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3063, in run_cell_async interactivity=interactivity, compiler=compiler, result=result) File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3254, in run_ast_nodes if (await self.run_code(code, result, async_=asy)): File "C:\Users\srith\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 18, in swap_channels=swap_channels) File "C:\Users\srith\SSD_Keras_GITHUB\keras_ssd300.py", line 358, in ssd_300 conv4_3_norm_mbox_priorbox_reshape = Reshape((-1, 8), name='conv4_3_norm_mbox_priorbox_reshape')(conv4_3_norm_mbox_priorbox) File "C:\Users\srith\anaconda3\lib\site-packages\keras\engine\topology.py", line 585, in __call__ output = self.call(inputs, **kwargs) File "C:\Users\srith\anaconda3\lib\site-packages\keras\layers\core.py", line 403, in call return K.reshape(inputs, (-1,) + target_shape) File "C:\Users\srith\anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 1694, in reshape return tf.reshape(x, shape) File "C:\Users\srith\anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 9093, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "C:\Users\srith\anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "C:\Users\srith\anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func return func(*args, **kwargs) File "C:\Users\srith\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op op_def=op_def) File "C:\Users\srith\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2005, in __init__ self._traceback = tf_stack.extract_stack() """ If this is a simple problem, please guide me on to the path where i should look at. Any help would be much appreciated
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.