question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tutorials don't work.

See original GitHub issue

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 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 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DyassKhalid007commented, Apr 21, 2020

same issues

1reaction
yokopi521commented, Dec 18, 2019

I’m having the same issues, too

Read more comments on GitHub >

github_iconTop Results From Across the Web

The problem with tutorials - Visual Studio Code
When I'm going through a tutorial, my eyes are scanning for blocks of code because I'm trying to learn by doing. I'm literally...
Read more >
How to Learn from Tutorials the Right Way - freeCodeCamp
Tutorials can be a good learning tool, but you have to go about it in the right way or else you can become...
Read more >
"Don't just watch tutorials and follow along, make sure ... - Reddit
I find tutorials extremely boring and slow. And they aren't a great way of teaching programming which is extremely hands-on. Just like you...
Read more >
How To Escape Tutorial Hell - In Plain English
The 5 Things That Helped Me Escape Tutorial Hell. ... What worked for others, didn't work for me. I thought I should change...
Read more >
Multiversus KBI Tutorial Not Working [FIXED] - eXputer.com
The KBI tutorial in Multiversus does not function & bugs out sometimes and stops working so let's discuss a couple of ways to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found