How to use the redisai.Backend function in redisai

To help you get started, we’ve selected a few redisai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RedisAI / redisai-py / test / test_model.py View on Github external
def testSKLearnGraph(self):
        sklearn_model, prototype = get_sklearn_model_and_prototype()
        path = f'{time.time()}.onnx'
        self.assertRaises(TypeError, save_model, sklearn_model, path)
        save_model(sklearn_model, path, prototype=prototype)
        model = load_model(path)
        os.remove(path)
        con = self.get_client()
        con.modelset('onnx_skl_model', Backend.onnx, Device.cpu, model)
        con.tensorset('a', Tensor.scalar(DType.float, *([1] * 13)))
        con.modelrun('onnx_skl_model', ['a'], ['outfromonnxskl'])
        tensor = con.tensorget('outfromonnxskl')
        self.assertEqual(len(tensor.value), 1)
github RedisAI / redisai-examples / python_client / linear_regression.py View on Github external
import redisai as rai
from ml2rt import load_model

model = load_model("../models/ONNX/boston.onnx")
con = rai.Client()
con.modelset("onnx_model", rai.Backend.onnx, rai.Device.cpu, model)

# dummydata taken from sklearn.datasets.load_boston().data[0]
dummydata = [
    0.00632, 18.0, 2.31, 0.0, 0.538, 6.575, 65.2, 4.09, 1.0, 296.0, 15.3, 396.9, 4.98]
tensor = rai.Tensor.scalar(rai.DType.float, *dummydata)
con.tensorset("input", tensor)

con.modelrun("onnx_model", ["input"], ["output"])
outtensor = con.tensorget("output", as_type=rai.BlobTensor)
print(f"House cost predicted by model is ${outtensor.to_numpy().item() * 1000}")