keras-team / autokeras

AutoML library for deep learning
http://autokeras.com/
Apache License 2.0
9.1k stars 1.4k forks source link

Autokers textinput text classifier does not work. #1903

Closed ferdasonmez closed 4 months ago

ferdasonmez commented 4 months ago

Hi, I am trying to use Autokeras to classify varied length of text (which are lines from a code file). I am hoping to get a model design thisway, however I am getting the below error. On purpose I did not tokenize or pad the data so that I am hoping the autokeras can provide the model which does that for me in a proper way. Regards, Ferda

File "C:\Programfiles\Python311\Lib\site-packages\autokeras\auto_model.py", line 344, in x_shapes = [a.shape for a in nest.flatten(x)] ^^^^^^^ AttributeError: 'str' object has no attribute 'shape'

    input_node = ak.TextInput()
    output_node = ak.TextBlock(block_type="ngram")(input_node)
    output_node = ak.ClassificationHead()(output_node)
    clf = ak.AutoModel(
        inputs=input_node, outputs=output_node, overwrite=True, max_trials=1
    )

    clf.fit(X_train_text, y_train[:, 0], epochs=2,  validation_data=(X_val_text, y_val))
    # Export as a Keras Model.
    model = clf.export_model()