Comments (2)
Simple explanation of how the TF model & the vocab are configured
The model is configured to work with vocabulary shaped like this:
[ string, string, string, string... n - string ]
Then when you're training or trying to get prediction there is a fitData
method, which receives string as input and returns sequence of numbers which tensorflow can understand. For example:
Input: "This app is really bad and the design ugly. It crashes and shows me a lot of ads. Just bad."
Vocabulary: [ "bad", "ugly", "crashes", "slow", "ads", "good", "beautiful", "fast", "worth" ]
Output of the fitData method: [ 2, 1, 1, 0, 1, 0, 0, 0, 0 ]
The output is an array, similar to the vocab but contains numbers - how many times a word from the vocab is used. Then a model is trained like this:
x layer: [ [ fitData output ], [ ... ], [ ... ], ... ]
y layer: [ [ number ], [ number ], ... ]
The y
layer is a 2d tensor, with a single integer for each value. In my case I use zeros and ones.
0 - negative, 1 - positive
But you can also set it up with more complex values to get more than 2 results. That's helpful when you try to label something.
Your question, @kenken64
The first layer (x
) is initialized by tf.layers.dense({ units: 2, inputShape: [vocabulary.length] })
, with inputShape
equial to vocabulary.length
, because it contains int value for each vocab item.
if i add new vocab how can i reconfigure the dense layer?
- If you wanna change the vocab items but keep the current shape, you won't need any changes on the model or its layers.
[ string, string, ... n strings ] // The length is not in significant importance, because the model automatically gets it via vocab.length
- If you think that the current shape won't fit your need, you should rethink the model. I can help you, but in order to keep the issues specific and helpful to others you can chat me on my e-mail [email protected] or join my Slackroom - sign up here http://rsg-slack.herokuapp.com/ and explaining your specific use case and ideas.
Resources
Few sources which might be helpful to you and anyone else:
- https://www.quora.com/What-is-the-bag-of-words-algorithm
- https://en.wikipedia.org/wiki/Bag-of-words_model
- https://machinelearningmastery.com/gentle-introduction-bag-words-model/
- https://www.youtube.com/watch?v=hgQTIMrGwtg
- https://cloud.google.com/blog/products/gcp/intro-to-text-classification-with-keras-automatically-tagging-stack-overflow-posts
from tfjs-firebase.
Closing it as a resolved. @kenken64, If you still have questions, feel free to comment on the issue again and reopen it, or file a new one. 😃 😃 😃 Also my e-mail and the Slackroom are linked above. 👍
from tfjs-firebase.
Related Issues (2)
- Please add a LICENSE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfjs-firebase.