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

Use TF model object as parameter in new redisai.Model #56

Open
CICCIOSGAMINO opened this issue Aug 9, 2022 · 1 comment
Open

Use TF model object as parameter in new redisai.Model #56

CICCIOSGAMINO opened this issue Aug 9, 2022 · 1 comment

Comments

@CICCIOSGAMINO
Copy link

CICCIOSGAMINO commented Aug 9, 2022

As a Node.js developer i'm using the redisai-js module to connect with Redis-Ai with my node.js application. So i'm using / save / load my models in TensorflowJs format (model.json, weights.bin) so its useful create the Redis-Ai model getting start from these two files saved. Actually the code i'm used doesn't work because the model format:

    const m = await tf.loadLayersModel(`file://model/AX-model/model.json`)
    const myModel = new redisai.Model(redisai.Backend.TF, 'CPU',['a','b'], ['c'], m)
    const r = await aiclient.modelset('mlmodel', myModel)

So i'm interesting to thinking at a solution, in node.js application i'm struggle to use Redis to save the TensorflowJs models too directly in-memory db. I'd like to chose which operation get done in Node.js application and which in Redis-Ai, so for example train the model in Node.js application and predict in Redis-Ai:

     const model = tf.sequential()
     model.add(tf.layers.dense({inputShape: [1], units: 1}))
     model.add(tf.layers.dense({units: 1}))
    model.compile({
           optimizer: 'sgd',   // tf.train.adam(),
           // loss: tf.losses.meanSquaredError,
           loss: 'meanSquaredError',
           metrics: ['mse']
      })

       const myModel = new redisai.Model(redisai.Backend.TF, 'CPU',['a','b'], ['c'], model)
       const r = await aiclient.modelset('mlmodel', myModel)
@chayim
Copy link
Contributor

chayim commented Aug 11, 2022

@leibale Want to have a look?

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

2 participants