Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tokenize text and prepare data for " model.predict() " ? #126

Open
TravJav opened this issue May 27, 2018 · 2 comments
Open

How to tokenize text and prepare data for " model.predict() " ? #126

TravJav opened this issue May 27, 2018 · 2 comments

Comments

@TravJav
Copy link

TravJav commented May 27, 2018

I have been looking through the documentation how to implement the prediction model in KerasJS but have been unsuccessful finding the correct context. I understand there is a boilerplate code available in js which just states that a float32 is used along with the callback and model.predict etc, I was able to use the encoder to convert the model h5 to the *bin required but in terms of tokenizing the text I do not see anything currently that is in the documents with KerasJS.

i've been successful using Python and the normal approach with Keras but am struggling to find concrete examples to do what is required for my project with KerasJS.

I have done the following with the Python for classification:

1. Create Tokenizer
2. Open a dictionary *json file containing the top 3000 words in
3. Implement keras.text_to_word_sequence (myText)
4. Make sure the words are registered in the dictionary
5. Tokenizer.sequences_to_matrix(input), binary
6. predict and receive the appropriate output

Can someone kindly explain to me or point me to the correct docs that I can follow to achieve this?

@zhuoli7
Copy link

zhuoli7 commented Jul 16, 2018

According to my understanding of keras.js documentation, I think they don't support Tokenizer. My solution is finishing all the preprocessing work in a flask app and send the ready-to-use sequence back for prediction. Although it's been a while, I hope this can help.

@hmhwe
Copy link

hmhwe commented Jan 9, 2019

What about the predicted output? How can we convert the predicted sequence of integers back to text? @zhuoli7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants