All the examples listed in https://autokeras.com/tutorial/ fail in version 1.0.0.
First example:
>>> import autokeras as ak
>>> from keras.datasets import mnist
Using TensorFlow backend.
>>>
>>> # Prepare the data.
... (x_train, y_train), (x_test, y_test) = mnist.load_data()
>>> x_train = x_train.reshape(x_train.shape + (1,))
>>> x_test = x_test.reshape(x_test.shape + (1,))
>>>
>>> # Search and train the classifier.
... clf = ak.ImageClassifier(max_trials=100)
>>> clf.fit(x_train, y_train)
2019-09-03 15:17:47.250598: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-09-03 15:17:47.271654: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz
2019-09-03 15:17:47.272577: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4e7f8e0 executing computations on platform Host. Devices:
2019-09-03 15:17:47.272623: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit
validation_split=validation_split)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 146, in prepare_data
x_val, y_val = validation_data
TypeError: 'NoneType' object is not iterable
Second example:
>>> import numpy as np
>>> import autokeras as ak
>>> from keras.datasets import mnist
>>>
>>> # Prepare the data.
... (x_train, y_classification), (x_test, y_test) = mnist.load_data()
>>> x_image = x_train.reshape(x_train.shape + (1,))
>>> x_test = x_test.reshape(x_test.shape + (1,))
>>>
>>> x_structured = np.random.rand(x_train.shape[0], 100)
>>> y_regression = np.random.rand(x_train.shape[0], 1)
>>>
>>> # Build model and train.
... automodel = ak.AutoModel(
... inputs=[ak.ImageInput(),
... ak.StructuredDataInput()],
... outputs=[ak.RegressionHead(metrics=['mae']),
... ak.ClassificationHead(loss='categorical_crossentropy',
... metrics=['accuracy'])])
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
AttributeError: module 'autokeras' has no attribute 'StructuredDataInput'
This error can be fixed by replacing StructuredDataInput with StructuredInput, but this still fails:
>>> import numpy as np
>>> import autokeras as ak
>>> from keras.datasets import mnist
>>>
>>> # Prepare the data.
... (x_train, y_classification), (x_test, y_test) = mnist.load_data()
>>> x_image = x_train.reshape(x_train.shape + (1,))
>>> x_test = x_test.reshape(x_test.shape + (1,))
>>>
>>> x_structured = np.random.rand(x_train.shape[0], 100)
>>> y_regression = np.random.rand(x_train.shape[0], 1)
>>>
>>> # Build model and train.
... automodel = ak.AutoModel(
... inputs=[ak.ImageInput(),
... ak.StructuredInput()],
... outputs=[ak.RegressionHead(metrics=['mae']),
... ak.ClassificationHead(loss='categorical_crossentropy',
... metrics=['accuracy'])])
>>> automodel.fit([x_image, x_structured],
... [y_regression, y_classification])
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit
validation_split=validation_split)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 131, in prepare_data
y = self._label_encoding(y)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 182, in _label_encoding
label_encoder.fit_with_labels(y)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/utils.py", line 153, in fit_with_labels
data = np.array(data).flatten()
ValueError: could not broadcast input array from shape (60000,1) into shape (60000)
Finally, the third example fails:
>>> import numpy as np
>>> import tensorflow as tf
>>> from keras.datasets import mnist
>>>
>>> # Prepare the data.
... (x_train, y_classification), (x_test, y_test) = mnist.load_data()
>>> x_image = x_train.reshape(x_train.shape + (1,))
>>> x_test = x_test.reshape(x_test.shape + (1,))
>>>
>>> x_structured = np.random.rand(x_train.shape[0], 100)
>>> y_regression = np.random.rand(x_train.shape[0], 1)
>>>
>>> # Build model and train.
... inputs = ak.ImageInput(shape=(28, 28, 1))
>>> outputs1 = ak.ResNetBlock(version='next')(inputs)
>>> outputs2 = ak.XceptionBlock()(inputs)
>>> image_outputs = ak.Merge()((outputs1, outputs2))
>>>
>>> structured_inputs = ak.StructuredInput()
>>> structured_outputs = ak.DenseBlock()(structured_inputs)
>>> merged_outputs = ak.Merge()((image_outputs, structured_outputs))
>>>
>>> classification_outputs = ak.ClassificationHead()(merged_outputs)
>>> regression_outputs = ak.RegressionHead()(merged_outputs)
>>> automodel = ak.GraphAutoModel(inputs=inputs,
... outputs=[regression_outputs,
... classification_outputs])
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 243, in __init__
self.hypermodel = graph.GraphHyperModel(self.inputs, self.outputs)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/hypermodel/graph.py", line 33, in __init__
self._build_network()
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/hypermodel/graph.py", line 135, in _build_network
'{name}.'.format(name=block.name))
ValueError: A required input is missing for HyperModel merge_4.
In my own example, the choice of validation data does not appear to work:
>>> import pandas as pd
>>> import autokeras as ak
>>> import numpy as np
>>>
>>> automodel = ak.auto_model.AutoModel(
... inputs=[ak.StructuredInput()],
... outputs=[
... ak.RegressionHead(metrics=['mae']),
... ak.ClassificationHead(loss='categorical_crossentropy', metrics=['accuracy'])
... ]
... )
>>>
>>> df = pd.read_csv("samples.csv")
>>> X = np.array(df[df.columns[:-4]])
>>> yr = np.array(df[["residuary_resistance", "doubled"]])
>>> yc = np.array(df[["animal", "colour"]])
>>>
>>>
>>> automodel.fit(x=[X], y=[yr, yc])
2019-09-03 15:23:55.991949: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-09-03 15:23:56.015636: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz
2019-09-03 15:23:56.016339: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4231040 executing computations on platform Host. Devices:
2019-09-03 15:23:56.016375: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit
validation_split=validation_split)
File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 146, in prepare_data
x_val, y_val = validation_data
TypeError: 'NoneType' object is not iterable
Expected behaviour is that the examples are able to run to the end.
Include the details about the versions of:
pip3 install git+git://github.com/keras-team/autokeras@master#egg=autokeras)Got the same issues here. The version I used for autoKeras is autokeras-1.0.0a0
Bug Description
Reproducing Steps
All the examples listed in https://autokeras.com/tutorial/ fail in version 1.0.0.
First example:
>>> import autokeras as ak >>> from keras.datasets import mnist Using TensorFlow backend. >>> >>> # Prepare the data. ... (x_train, y_train), (x_test, y_test) = mnist.load_data() >>> x_train = x_train.reshape(x_train.shape + (1,)) >>> x_test = x_test.reshape(x_test.shape + (1,)) >>> >>> # Search and train the classifier. ... clf = ak.ImageClassifier(max_trials=100) >>> clf.fit(x_train, y_train) 2019-09-03 15:17:47.250598: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2019-09-03 15:17:47.271654: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz 2019-09-03 15:17:47.272577: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4e7f8e0 executing computations on platform Host. Devices: 2019-09-03 15:17:47.272623: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit validation_split=validation_split) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 146, in prepare_data x_val, y_val = validation_data TypeError: 'NoneType' object is not iterableSecond example:
>>> import numpy as np >>> import autokeras as ak >>> from keras.datasets import mnist >>> >>> # Prepare the data. ... (x_train, y_classification), (x_test, y_test) = mnist.load_data() >>> x_image = x_train.reshape(x_train.shape + (1,)) >>> x_test = x_test.reshape(x_test.shape + (1,)) >>> >>> x_structured = np.random.rand(x_train.shape[0], 100) >>> y_regression = np.random.rand(x_train.shape[0], 1) >>> >>> # Build model and train. ... automodel = ak.AutoModel( ... inputs=[ak.ImageInput(), ... ak.StructuredDataInput()], ... outputs=[ak.RegressionHead(metrics=['mae']), ... ak.ClassificationHead(loss='categorical_crossentropy', ... metrics=['accuracy'])]) Traceback (most recent call last): File "<stdin>", line 4, in <module> AttributeError: module 'autokeras' has no attribute 'StructuredDataInput'This error can be fixed by replacing
StructuredDataInputwithStructuredInput, but this still fails:>>> import numpy as np >>> import autokeras as ak >>> from keras.datasets import mnist >>> >>> # Prepare the data. ... (x_train, y_classification), (x_test, y_test) = mnist.load_data() >>> x_image = x_train.reshape(x_train.shape + (1,)) >>> x_test = x_test.reshape(x_test.shape + (1,)) >>> >>> x_structured = np.random.rand(x_train.shape[0], 100) >>> y_regression = np.random.rand(x_train.shape[0], 1) >>> >>> # Build model and train. ... automodel = ak.AutoModel( ... inputs=[ak.ImageInput(), ... ak.StructuredInput()], ... outputs=[ak.RegressionHead(metrics=['mae']), ... ak.ClassificationHead(loss='categorical_crossentropy', ... metrics=['accuracy'])]) >>> automodel.fit([x_image, x_structured], ... [y_regression, y_classification]) Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit validation_split=validation_split) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 131, in prepare_data y = self._label_encoding(y) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 182, in _label_encoding label_encoder.fit_with_labels(y) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/utils.py", line 153, in fit_with_labels data = np.array(data).flatten() ValueError: could not broadcast input array from shape (60000,1) into shape (60000)Finally, the third example fails:
>>> import numpy as np >>> import tensorflow as tf >>> from keras.datasets import mnist >>> >>> # Prepare the data. ... (x_train, y_classification), (x_test, y_test) = mnist.load_data() >>> x_image = x_train.reshape(x_train.shape + (1,)) >>> x_test = x_test.reshape(x_test.shape + (1,)) >>> >>> x_structured = np.random.rand(x_train.shape[0], 100) >>> y_regression = np.random.rand(x_train.shape[0], 1) >>> >>> # Build model and train. ... inputs = ak.ImageInput(shape=(28, 28, 1)) >>> outputs1 = ak.ResNetBlock(version='next')(inputs) >>> outputs2 = ak.XceptionBlock()(inputs) >>> image_outputs = ak.Merge()((outputs1, outputs2)) >>> >>> structured_inputs = ak.StructuredInput() >>> structured_outputs = ak.DenseBlock()(structured_inputs) >>> merged_outputs = ak.Merge()((image_outputs, structured_outputs)) >>> >>> classification_outputs = ak.ClassificationHead()(merged_outputs) >>> regression_outputs = ak.RegressionHead()(merged_outputs) >>> automodel = ak.GraphAutoModel(inputs=inputs, ... outputs=[regression_outputs, ... classification_outputs]) Traceback (most recent call last): File "<stdin>", line 3, in <module> File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 243, in __init__ self.hypermodel = graph.GraphHyperModel(self.inputs, self.outputs) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/hypermodel/graph.py", line 33, in __init__ self._build_network() File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/hypermodel/graph.py", line 135, in _build_network '{name}.'.format(name=block.name)) ValueError: A required input is missing for HyperModel merge_4.In my own example, the choice of validation data does not appear to work:
>>> import pandas as pd >>> import autokeras as ak >>> import numpy as np >>> >>> automodel = ak.auto_model.AutoModel( ... inputs=[ak.StructuredInput()], ... outputs=[ ... ak.RegressionHead(metrics=['mae']), ... ak.ClassificationHead(loss='categorical_crossentropy', metrics=['accuracy']) ... ] ... ) >>> >>> df = pd.read_csv("samples.csv") >>> X = np.array(df[df.columns[:-4]]) >>> yr = np.array(df[["residuary_resistance", "doubled"]]) >>> yc = np.array(df[["animal", "colour"]]) >>> >>> >>> automodel.fit(x=[X], y=[yr, yc]) 2019-09-03 15:23:55.991949: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2019-09-03 15:23:56.015636: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1992000000 Hz 2019-09-03 15:23:56.016339: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4231040 executing computations on platform Host. Devices: 2019-09-03 15:23:56.016375: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 101, in fit validation_split=validation_split) File "/home/michael/MonolithApp/dpu/venv/src/autokeras/autokeras/auto_model.py", line 146, in prepare_data x_val, y_val = validation_data TypeError: 'NoneType' object is not iterableExpected Behavior
Expected behaviour is that the examples are able to run to the end.
Setup Details
Include the details about the versions of:
- OS type and version: Ubuntu 18.04.3 LTS
- Python: 3.6.8
- autokeras: 1.0.0 (
pip3 install git+git://github.com/keras-team/autokeras@master#egg=autokeras)- scikit-learn: 0.20.2
- numpy: 1.16.1
- keras: 2.2.4
- scipy: 1.2.0
- tensorflow: 2.0.0rc0
- pytorch: 1.0.1post2
For the first example, you can reform the 'clf.fit(x_train, y_train)' into 'clf.fit(x_train, y_train, validation_data=(x_test, y_test))'.
For the second example, you should reshape the y_classification with 'y_classification.reshape(-1, 1)'. And if you get an 'MemoryError', just slice the data to run a mini set.
For the third example, you can see we only pass 'inputs' into the GraphAutoModel, actually this 'inputs' is only the image input while we also need to input the 'structured_inputs', so change the present code to 'inputs=[inputs, structured_inputs]'. We will change the name of 'inputs' into 'image_inputs' to make it sense.
We will patch this bugs in a few days.
Thank U and welcome the continuing issue reports!
For the first example, you can reform the 'clf.fit(x_train, y_train)' into 'clf.fit(x_train, y_train, validation_data=(x_test, y_test))'.
Results in a different error for me.
ValueError: Tensor conversion requested dtype float64 for Tensor with dtype float32:
<tf.Tensor: id=240045, shape=(28, 28, 1), dtype=float32, numpy=array([[[nan],
[nan],
...,
[nan],
[nan]]],
dtype=float32)>
edit: Solved by casting the MNIST data to np.float64.
I tried
For the first example, you can reform the 'clf.fit(x_train, y_train)' into 'clf.fit(x_train, y_train, validation_data=(x_test, y_test))'.
and
Solved by casting the MNIST data to np.float64,
it started training for a few epochs, but it stopped with the following error:
~/anaconda3/envs/autokeras10/lib/python3.6/site-packages/tensorflow_core/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
65 else:
66 message = e.message
---> 67 six.raise_from(core._status_to_exception(e.code, message), None)
68 except TypeError as e:
69 keras_symbolic_tensors = [~/anaconda3/envs/autokeras10/lib/python3.6/site-packages/six.py in raise_from(value, from_value)
UnknownError: {{function_node __inference_Dataset_map_
_1446651}} InvalidArgumentError: input must have 3 channels but instead has 1 channels. [Op:AdjustSaturation]
Traceback (most recent call last):
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.
Has this been fixed?
I'm having the exact same issues with installation
I'm having the same issues, too
same issues