__array__() takes 1 positional argument but 2 were given

Hi

When I try to train a multi-label image classification model, it gives error:
indent preformatted text by 4 spaces

TypeError Traceback (most recent call last)
in
----> 1 vgghist = model.fit(train_generator, validation_data = validation_generator, steps_per_epoch = 100, epochs = 10)

/usr/local/lib/python3.6/dist-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)
1145 use_multiprocessing=use_multiprocessing,
1146 model=self,
→ 1147 steps_per_execution=self._steps_per_execution)
1148
1149 # Container that configures and calls tf.keras.Callbacks.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in get_data_handler(*args, **kwargs)
1362 if getattr(kwargs[“model”], “_cluster_coordinator”, None):
1363 return _ClusterCoordinatorDataHandler(*args, **kwargs)
→ 1364 return DataHandler(*args, **kwargs)
1365
1366

/usr/local/lib/python3.6/dist-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, steps_per_execution, distribute)
1164 use_multiprocessing=use_multiprocessing,
1165 distribution_strategy=ds_context.get_strategy(),
→ 1166 model=model)
1167
1168 strategy = ds_context.get_strategy()

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weights, shuffle, workers, use_multiprocessing, max_queue_size, model, **kwargs)
937 max_queue_size=max_queue_size,
938 model=model,
→ 939 **kwargs)
940
941 @staticmethod

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weights, workers, use_multiprocessing, max_queue_size, model, **kwargs)
807 # Since we have to know the dtype of the python generator when we build the
808 # dataset, we have to look at a batch to infer the structure.
→ 809 peek, x = self._peek_and_restore(x)
810 peek = self._standardize_batch(peek)
811 peek = _process_tensorlike(peek)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in _peek_and_restore(x)
941 @staticmethod
942 def _peek_and_restore(x):
→ 943 return x[0], x
944
945 def _handle_multiprocessing(self, x, workers, use_multiprocessing,

/usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/iterator.py in getitem(self, idx)
63 index_array = self.index_array[self.batch_size * idx:
64 self.batch_size * (idx + 1)]
—> 65 return self._get_batches_of_transformed_samples(index_array)
66
67 def len(self):

/usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/iterator.py in _get_batches_of_transformed_samples(self, index_array)
229 target_size=self.target_size,
230 interpolation=self.interpolation)
→ 231 x = img_to_array(img, data_format=self.data_format)
232 # Pillow images should be closed after load_img,
233 # but not PIL images.

/usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/utils.py in img_to_array(img, data_format, dtype)
307 # or (channel, height, width)
308 # but original PIL image has format (width, height, channel)
→ 309 x = np.asarray(img, dtype=dtype)
310 if len(x.shape) == 3:
311 if data_format == ‘channels_first’:

/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
81
82 “”"
—> 83 return array(a, dtype, copy=False, order=order)
84
85

TypeError: array() takes 1 positional argument but 2 were given

Please help. Thanks

Could you provide code snippet to replicate your issue.