GithubHelp home page GithubHelp logo

Comments (2)

radi-cho avatar radi-cho commented on August 10, 2024

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:

from tfjs-firebase.

radi-cho avatar radi-cho commented on August 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.