Closed max1563 closed 4 years ago
I'm also having this issue and seems a duplicate of #1095.
It works with tensorflow 2.1.0 but I need to use a newer version to be able to export the model.
I am also facing the same issue on the titanic survival problem I got from the following link. https://autokeras.com/examples/titanic/
I have also done some tweaking.
import autokeras as ak
clf = ak.StructuredDataClassifier(max_trials=30)
clf.fit(x=train, y=train[['survived']])
print('Accuracy: {accuracy}'.format(accuracy=clf.evaluate(x=eval, y=eval[['survived']])))
Change the imports to
from keras.optimizers import Adam
from keras.callbacks import EarlyStopping
from keras.layers import Dense
from keras.layers import Dropout
from keras import models
This is fixed in 1.0.3 release. You can also export the model with 1.0.3. Thanks.
Bug Description
Simply copy-pasting the code from the example usage for TextClassification gives the following error in Colab:
`/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 966 except Exception as e: # pylint:disable=broad-except 967 if hasattr(e, "ag_error_metadata"): --> 968 raise e.ag_error_metadata.to_exception(e) 969 else: 970 raise
AttributeError: in user code:
`
Bug Reproduction
Code for reproducing the bug:
` import numpy as np from tensorflow.keras.datasets import imdb index_offset = 3 # word index offset (x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=1000, index_from=index_offset) y_train = y_train.reshape(-1, 1) y_test = y_test.reshape(-1, 1) word_to_id = imdb.get_word_index() word_to_id = {k: (v + index_offset) for k, v in word_to_id.items()} word_to_id[""] = 0
word_to_id[""] = 1
word_to_id[""] = 2
id_to_word = {value: key for key, value in word_to_id.items()}
x_train = list(map(lambda sentence: ' '.join(
id_to_word[i] for i in sentence), x_train))
x_test = list(map(lambda sentence: ' '.join(
id_to_word[i] for i in sentence), x_test))
x_train = np.array(x_train, dtype=np.str)
x_test = np.array(x_test, dtype=np.str)
print(x_train.shape) # (25000,)
print(y_train.shape) # (25000, 1)
print(x_train[0][:50]) # this film was just brilliant casting
import autokeras as ak clf = ak.TextClassifier(max_trials=10) # It tries 10 different models. clf.fit(x_train, y_train) predicted_y = clf.predict(x_test) print(clf.evaluate(x_test, y_test)) `
Expected Behavior
Setup Details
Include the details about the versions of:
Additional context