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.

Low eval accuracy for TextClassifier (Might because of cannot save text_vectorization)

See original GitHub issue

I have run the Text Classification example here: https://autokeras.com/tutorial/text_classification/

My validation accuracy gets to the high 90s, but when I run inference on the test set, it is close to 50%. There’s nothing inherently wrong with that if that’s the expected output. However, it looks as though it is just using the last model trained and not the best model based on the printed results from the last model being trained.

Also, when I run clf.evaluate(x_train, y_train) I get the same results of 50% accuracy. I apologize if I’m missing something obvious here, but this does not look right to me.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
haifeng-jincommented, Feb 12, 2020

@dzimmerman-nci Thank you for the work solution! Hope tf would release this “fit to adapt” feature soon.

1reaction
dzimmerman-ncicommented, Feb 11, 2020

@haifeng-jin it seems the only way to get it to work is if I retrain the exported Keras model after adapting the TextVectorization layer like this:

auto_keras_model = ak.TextClassifier(max_trials=3)
auto_keras_model.fit(x_train, y_train)
keras_model = auto_keras_model.export_model()
text_vectorization_layer = keras_model.layers[1]
text_vectorization_layer.adapt(x_train)
keras_model.fit(x_train, y_train)
print(keras_model.evaluate(x_test, y_test))

If I exclude the keras_model.fit(x_train, y_train) line, I get the same results as I do when I do not adapt the TextVectorization layer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to save TextVectorization to disk in tensorflow?
You can try using following code snippet to save vectorized data into pickle format pickle.dump(vectorized_text, open("vector.pickel", "wb")) ...
Read more >
Can't save TextVectorization model. I just failed the ... - Reddit
I just failed the exam because I couldn't save it. This isn't from the exam. This is the kaggle dataset on NLP I...
Read more >
model.save and load giving different result #4875 - GitHub
I am trying to save a simple LSTM model for text classification. The input of the model is padded vectorized sentences. model =...
Read more >
Basic text classification | TensorFlow Core
This notebook trains a sentiment analysis model to classify movie reviews as positive or negative, based on the text of the review. This...
Read more >
Text classification from scratch - Keras
Introduction. This example shows how to do text classification starting from raw text (as a set of text files on disk). We demonstrate...
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