Skip to content

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

@CICCIOSGAMINO

Description

@CICCIOSGAMINO

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions