DeepCTR icon indicating copy to clipboard operation
DeepCTR copied to clipboard

Error - Failed to convert a NumPy array to a Tensor (Unsupported object type list).

Open pythonmjs opened this issue 5 years ago • 1 comments

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list).


Hello folks, Can you help me with this error? I am creating binary video classification and using image_generator for generating and feeding data in batch and from the individual video(40 frames per video) but it keeps showing me an error like this.


ValueError Traceback (most recent call last) in ----> 1 model.fit_generator(generator=train_generator,validation_data=validation_generator, use_multiprocessing=True, epochs=100) 2 model.save_weights('one-more.h5')

~/.local/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs) 322 'in a future version' if date is None else ('after %s' % date), 323 instructions) --> 324 return func(*args, **kwargs) 325 return tf_decorator.make_decorator( 326 func, new_func, 'deprecated',

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch) 1477 use_multiprocessing=use_multiprocessing, 1478 shuffle=shuffle, -> 1479 initial_epoch=initial_epoch) 1480 1481 @deprecation.deprecated(

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs) 64 def _method_wrapper(self, *args, **kwargs): 65 if not self._in_multi_worker_mode(): # pylint: disable=protected-access ---> 66 return method(self, *args, **kwargs) 67 68 # Running inside run_distribute_coordinator already.

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing) 813 workers=workers, 814 use_multiprocessing=use_multiprocessing, --> 815 model=self) 816 817 # Container that configures and calls tf.keras.Callbacks.

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model) 1110 use_multiprocessing=use_multiprocessing, 1111 distribution_strategy=ds_context.get_strategy(), -> 1112 model=model) 1113 1114 strategy = ds_context.get_strategy()

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weights, workers, use_multiprocessing, max_queue_size, model, **kwargs) 773 assert_not_namedtuple(peek) 774 peek = self._standardize_batch(peek) --> 775 peek = _process_tensorlike(peek) 776 777 # Need to build the Model on concrete input shapes.

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/data_adapter.py in _process_tensorlike(inputs) 1011 return x 1012 -> 1013 inputs = nest.map_structure(_convert_numpy_and_scipy, inputs) 1014 return nest._list_to_tuple(inputs) # pylint: disable=protected-access 1015

~/.local/lib/python3.5/site-packages/tensorflow/python/util/nest.py in map_structure(func, *structure, **kwargs) 615 616 return pack_sequence_as( --> 617 structure[0], [func(*x) for x in entries], 618 expand_composites=expand_composites) 619

~/.local/lib/python3.5/site-packages/tensorflow/python/util/nest.py in (.0) 615 616 return pack_sequence_as( --> 617 structure[0], [func(*x) for x in entries], 618 expand_composites=expand_composites) 619

~/.local/lib/python3.5/site-packages/tensorflow/python/keras/engine/data_adapter.py in _convert_numpy_and_scipy(x) 1006 if issubclass(x.dtype.type, np.floating): 1007 dtype = backend.floatx() -> 1008 return ops.convert_to_tensor(x, dtype=dtype) 1009 elif scipy_sparse and scipy_sparse.issparse(x): 1010 return _scipy_sparse_to_sparse_tensor(x)

~/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types) 1339 1340 if ret is None: -> 1341 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) 1342 1343 if ret is NotImplemented:

~/.local/lib/python3.5/site-packages/tensorflow/python/framework/tensor_conversion_registry.py in _default_conversion_function(failed resolving arguments) 50 def _default_conversion_function(value, dtype, name, as_ref): 51 del as_ref # Unused. ---> 52 return constant_op.constant(value, dtype, name=name) 53 54

~/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name) 260 """ 261 return _constant_impl(value, dtype, shape, name, verify_shape=False, --> 262 allow_broadcast=True) 263 264

~/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast) 268 ctx = context.context() 269 if ctx.executing_eagerly(): --> 270 t = convert_to_eager_tensor(value, ctx, dtype) 271 if shape is None: 272 return t

~/.local/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype) 94 dtype = dtypes.as_dtype(dtype).as_datatype_enum 95 ctx.ensure_initialized() ---> 96 return ops.EagerTensor(value, ctx.device_name, dtype) 97 98 ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list).


PS: x,y=next(train_generator) print(x.shape,y.shape) result: starting index: 512 (208, 40, 224, 224, 3) (208, 2) in the last batch, it has 208 videos, having 40 frames in every videos(converted) and shape.

pythonmjs avatar Oct 16 '20 19:10 pythonmjs

Please use the bug report template to show your environment and the reproduction of the error.

Describe the bug A clear and concise description of what the bug is.Better with standalone code to reproduce the issue.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Operating environment:

  • python version [e.g. 3.6, 3.7]
  • tensorflow version [e.g. 1.4.0, 1.15.0, 2.5.0]
  • deepctr version [e.g. 0.8.6,]

Additional context Add any other context about the problem here.

zanshuxun avatar Aug 24 '21 04:08 zanshuxun