Autokeras: tf.data.Dataset not support! [bug]

Created on 2 Feb 2020  路  1Comment  路  Source: keras-team/autokeras

Bug Description


run with tensorflow_datasets 's mnist dataset, but show error message:
AttributeError: 'TakeDataset' object has no attribute 'shape'

Reproducing Steps

# run codes:
import tensorflow_datasets as tfds
mnist_train = tfds.load('mnist', split="train", as_supervised=True)
import autokeras as ak
ak0 = ak.ImageClassifier(num_classes=10, max_trials=10)
ak0.fit(mnist_train, epochs=10)

Expected Behavior

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-a90e48684d55> in <module>
----> 1 ak0.fit(mnist_train, epochs=10)

~/anaconda3/lib/python3.7/site-packages/autokeras/tasks/image.py in fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)
    119                     validation_split=validation_split,
    120                     validation_data=validation_data,
--> 121                     **kwargs)
    122 
    123 

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in fit(self, x, y, batch_size, epochs, callbacks, validation_split, validation_data, **kwargs)
    229             y=y,
    230             validation_data=validation_data,
--> 231             validation_split=validation_split)
    232 
    233         # Process the args.

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _prepare_data(self, x, y, validation_data, validation_split)
    303         # TODO: Handle other types of input, zip dataset, tensor, dict.
    304         # Prepare the dataset.
--> 305         dataset = self._process_xy(x, y, True)
    306         if validation_data:
    307             self._split_dataset = False

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_xy(self, x, y, fit)
    291 
    292         x = self._process_x(x, fit)
--> 293         y = self._process_y(y, fit)
    294 
    295         return tf.data.Dataset.zip((x, y))

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_y(self, y, fit)
    267         for data, head, adapter in zip(y, self._heads, self._output_adapters):
    268             if fit:
--> 269                 data = adapter.fit_transform(data)
    270             else:
    271                 data = adapter.transform(data)

~/anaconda3/lib/python3.7/site-packages/autokeras/engine/adapter.py in fit_transform(self, dataset)
     66     def fit_transform(self, dataset):
     67         self.check(dataset)
---> 68         self.fit_before_convert(dataset)
     69         dataset = self.convert_to_dataset(dataset)
     70         self.fit(dataset)

~/anaconda3/lib/python3.7/site-packages/autokeras/adapters/output_adapter.py in fit_before_convert(self, dataset)
     65         if isinstance(dataset, tf.data.Dataset):
     66             if not self.num_classes:
---> 67                 shape = dataset.take(1).shape[1]
     68                 if shape == 1:
     69                     self.num_classes = 2

AttributeError: 'TakeDataset' object has no attribute 'shape'

Setup Details

Include the details about the versions of:

  • OS type and version:
  • Python:
  • autokeras: 1.0.1
  • scikit-learn:
  • numpy:
  • keras:
  • scipy:
  • tensorflow: 2.1.0
  • pytorch:

Additional context


TakeDataset doesn't have attribute 'shape', so the code may be wrong. You can also find I have set num_classes=10, so there are several bugs, not just one.

bug report pinned

Most helpful comment

@ytian Thank you for the issue! We will look into it.

>All comments

@ytian Thank you for the issue! We will look into it.

Was this page helpful?
0 / 5 - 0 ratings